Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress How to Build a WordPress Theme Preparing to Code WordPress Templates Linking JavaScript

Adding my javascript to my function.php

Hi Please I was trying to do a wp_enqueue_script for the following code in on of my html templates but it seems like it is not working out. It kind of looks more complicated than the one we are doing.Please can you help out.

<script src="../assets/components/plugins/ajaxify/script.min.js?v=v1.9.6&sv=v0.0.1"></script>

<script>var App = {};</script>

<script data-id="App.Scripts">
App.Scripts = {

    /* CORE scripts always load first; */
    core: [
        '../assets/components/library/jquery/jquery.min.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/library/modernizr/modernizr.js?v=v1.9.6&sv=v0.0.1'
    ],

    /* PLUGINS_DEPENDENCY always load after CORE but before PLUGINS; */
    plugins_dependency: [
        '../assets/components/library/bootstrap/js/bootstrap.min.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/library/jquery/jquery-migrate.min.js?v=v1.9.6&sv=v0.0.1'
    ],

    /* PLUGINS always load after CORE and PLUGINS_DEPENDENCY, but before the BUNDLE / initialization scripts; */
    plugins: [
        '../assets/components/plugins/nicescroll/jquery.nicescroll.min.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/plugins/breakpoints/breakpoints.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/plugins/ajaxify/davis.min.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/plugins/ajaxify/jquery.lazyjaxdavis.min.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/plugins/preload/pace/pace.min.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/plugins/owl-carousel/owl.carousel.min.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/common/forms/elements/bootstrap-select/assets/lib/js/bootstrap-select.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/plugins/less-js/less.min.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/modules/admin/charts/flot/assets/lib/excanvas.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/plugins/browser/ie/ie.prototype.polyfill.js?v=v1.9.6&sv=v0.0.1'
    ],

    /* The initialization scripts always load last and are automatically and dynamically loaded when AJAX navigation is enabled; */
    bundle: [
        '../assets/components/plugins/ajaxify/ajaxify.init.js?v=v1.9.6', 
        '../assets/components/core/js/preload.pace.init.js?v=v1.9.6', 
        '../assets/components/modules/admin/content/assets/news-featured-2.init.js?v=v1.9.6', 
        '../assets/components/modules/admin/content/assets/news-featured-1.init.js?v=v1.9.6', 
        '../assets/components/modules/admin/content/assets/news-featured-3.init.js?v=v1.9.6', 
        '../assets/components/core/js/sidebar.main.init.js?v=v1.9.6', 
        '../assets/components/core/js/sidebar.collapse.init.js?v=v1.9.6', 
        '../assets/components/common/forms/elements/bootstrap-select/assets/custom/js/bootstrap-select.init.js?v=v1.9.6&sv=v0.0.1', 
        '../assets/components/core/js/sidebar.kis.init.js?v=v1.9.6', 
        '../assets/components/core/js/core.init.js?v=v1.9.6', 
        '../assets/components/core/js/animations.init.js?v=v1.9.6'
    ]

};
</script>

<script>
$script(App.Scripts.core, 'core');

$script.ready(['core'], function(){
    $script(App.Scripts.plugins_dependency, 'plugins_dependency');
});
$script.ready(['core', 'plugins_dependency'], function(){
    $script(App.Scripts.plugins, 'plugins');
});
$script.ready(['core', 'plugins_dependency', 'plugins'], function(){
    $script(App.Scripts.bundle, 'bundle');
});
</script>
    <script>if (/*@cc_on!@*/false && document.documentMode === 10) { document.documentElement.className+=' ie ie10'; }</script>

1 Answer

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Okay, the first problem is that this video shows how to load JS stored in an external JavaScript file. This is all JavaScript that get's embedded directly into an HTML file so that approach won't work.

The bigger question though is why do you need to load all of this JavaScript?