treehouse : what would you like to learn today?
Web Design Web Development iOS Development

!window.jQuery.ui Problem in WordPress

  • I am working on a WordPress website, and I need to include this to a page. BUT there is this code that does not let me integrate it.

    <script>!window.jQuery && document.write(unescape('%3Cscript src="js/jquery-1.7.2.min.js"%3E%3C/script%3E'))</script>

    Any idea how to make it work in WordPress?

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script&gt;
    <script>!window.jQuery && document.write(unescape('%3Cscript src="js/jquery-1.7.2.min.js"%3E%3C/script%3E'))</script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script&gt;
    <script>!window.jQuery.ui && document.write(unescape('%3Cscript src="js/jquery-ui-1.8.21.custom.min.js"%3E%3C/script%3E'))</script>
    <script src="js/jquery.mousewheel.min.js"></script>
    <script src="js/jquery.mCustomScrollbar.js"></script>
    <script src="js/scrollbar.js"></script>

    Thanks,

  • Have you tried any of these options? remove the spaces from my script tags

    < script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" >< /script >  
    < script >window.jQuery || document.write("\x3C/script >")< /script >
    
    < script src="http://ajax. googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" >< /script >
    < script >window.jQuery.ui || document.write("< script src='js/jqueryui.js' >\x3C/script>")< /script >
    

    or use javascript...

    (function test_jQuery() {
        if (!window.jQuery) {
            var script = document.createElement('script');
            script.src = "js/jquery.js";
            document.getElementsByTagName('head')[0].appendChild(script);
        }
        if (!window.jQuery.ui) {
            var script_ui = document.createElement('script');
            script_ui.src = "js/jquery-ui.js";
            document.getElementsByTagName('head')[0].appendChild(script_ui);
        }
    })();

    You dont need the anonymous function, its just habit for me.