Skip to content

Nicer code, Better compression, Ability to call nbl.l() multiple times#3

Open
tahajahangir wants to merge 11 commits into
berklee:masterfrom
tahajahangir:master
Open

Nicer code, Better compression, Ability to call nbl.l() multiple times#3
tahajahangir wants to merge 11 commits into
berklee:masterfrom
tahajahangir:master

Conversation

@tahajahangir
Copy link
Copy Markdown

No description provided.

@berklee
Copy link
Copy Markdown
Owner

berklee commented Mar 3, 2012

Thanks for your contribution. Could you please give me some more background, as the diff just replaces all code wholesale?

@tahajahangir
Copy link
Copy Markdown
Author

First of all, I decided to change the NBL a bit (as in third commit), but i found the code unreadable (it was like a minfied or obfuscated code). It appears you had used short varialbe and function names to reduce the code size, but it can achieved by using a good minifier (like google clousre compiler).

At first commit, I only changed variable names (to meaningful ones) and also i converted object like structrue of NBL to function. So NBL is now a function with local variables rather than an object with multiple properties.
This is more common and more readable, and also leads to a smaller compacted file.

At second commit, i changed the NBL to be jslint compliant. There are some small changes like converting "a && b()" to "if (a){ b();}". Note that google closure converted it back to "a && b()" at compile time ;)

The third commit, is my goal to change NBL. The problem is that multiple calls to "nbl.l(['myscript.js'])" will add "myscript.js" to <head> multiple times. I used NBL at a situation like this:

document.getElementById('showCalendar').onclick = function(){
    // Try to load calendar scripts files
    nbl.l([ ['calendar_script.js'], function() {
            // script is loaded
            showCalendar();
        }]);
};

I excpected that 'calendar_script.js' added to <head> once, but the new <script> is added with every call to nbl.l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants