byuweb / HTML-Templates

Development for BYU responsive theme
http://byuweb.github.io/HTML-Templates/
9 stars 9 forks source link

init.js #67

Closed dalemurri closed 10 years ago

dalemurri commented 11 years ago

I love the init.js, but there are some problems I am having with it. First, it would be nice to add a test for the jquery part, to ensure that it has been loaded. For example, I am loading it on my own, because of timing issues with this script. But if it loads it twice, then that is obviously wasted resources. So something as simple as the following could work:


 Modernizr.load([ // Load jQuery first. If it doesn't make it from our location, get it from Google.
    {
    test: jQuery,
        nope: 'http://byuweb.github.io/Global-Assets/js/jquery-1.9.1.min.js',
        complete: function() {
            if (!window.jQuery) {
                Modernizr.load("//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js");
            }
        }
    }, . . .

Then if jQuery is already loaded it doesn't do it again. Also the way this script is done does not allow for me to run jQuery.noConflict(); without modifying the code, which I am trying not to do.

It would be nice if there was a way that we as users to just add some other scripts that need to be loaded to a variable that got passed into the init function and have that code run in addition to what you are already running. As it is, I have to do that in my own code, and it can be a challenge to ensure that all javascript needed is loaded at the right time.

If you need to talk about it let me know, maybe we could meet and talk over some ideas.

esng25 commented 11 years ago

Thanks for the input. Would you be able to attend our meeting on Thursday? We have open meetings every Thursday at 1pm at the CTL (Back of the HBLL.) If you would like to, you can create a pull request which we will review and commit it.

Thanks again!

dalemurri commented 11 years ago

I'll see what I can do about being there.

nwalton3 commented 10 years ago

I've added the jQuery check you asked for. Also added a settings object in the head of the document where stuff can be specified. See init.js and any html file and let me know what you think. Thanks for the input!