BS-Harou

Just another blog about the best browser - Opera!

Subscribe to RSS feed

Posts tagged with "script"

Modular injected scripts in extensions

, , , ...

Recently in one of my blog posts I mentioned great library Require.JS. It has an API to load JavaScript snippets as modules. It works really great with popup files or with background file in speed dial extension.

Unfortunately, you can't use it in injected scripts for several reasons.
  1. Require.JS loads the snippets with script tags and we don't want to add any script tags to every page when our extensions is running.
  2. Even if it wouldn't be a problem we still can't load scripts from our extension package with script tag.
  3. Script tags also has it's own browser scope without the special Opera Extension APIs.
The conclusion is that Require.JS is useless when it comes to injected scripts. What we can do is to split our script to several injected script files. But such files have to use global scope to communicate and they are executed in alphabetical order.

Luckily, latest snapshot of Opera 12.50 Next has the new Resource Loader API. It is just one function which returns reference to "File" object of any file in our extension oex package.

Read more...

June 2013
M T W T F S S
May 2013July 2013
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30