This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

A little JS load confusion?

  • Creator
    Topic
  • #1557
    karlo
    Participant

    Not really a question and possible I need to re-read docs but I have been confused about FlexSlider and Roundabout loading all the time – even if docs and JS files say they should not. They are also only registered in general.php:

    // Register scripts — These scripts are only enque’d as needed.

    I could not nod to that.

    Then I figured out why. “Jump Start Scripts” In theme-functions.php. That little JS files is set up to have ALL JS files as dependencies so as long as that is untouched everything will load. Including the 2 slider scripts even if only registered.

    So I can replace themeblvd_include_scripts function. I can change $themeblvd_framework_scripts variable with all the handles used by “jumpstart_scripts”. I can do both and will get my way. But if I just sit and watch everything will load. Might as well enque FlexSlider and Roundabout but then they load – and they should not. ???

    If not wrong and if it does not say directly in docs I think it should be added that the easiest way to take full control of all JS files is to first deal with “Jump Start Scripts” theme.js file/action since it fire off so much.

    I can see why I did not think so much of theme.js I never paid any attention to it as I use own JS files. So I do not meet the assumption that 1 child theme = 1 new born theme.js = problem vanish.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #1558
    karlo
    Participant

    Hmm, now I check again it says in general.php

    // Framework scripts. This can be used declare the
    // $deps of any enque’d JS files intended to come after
    // the framework.

    Like a hint one is supposed to do this, replace entire function if not happy with defaults.

    Ok, is not big problem but is it clear from docs?

    #1567
    Jason Bobich
    Keymaster

    I think the error on my part is that there’s no need for flexslider and roundabout to be in that $deps array at all. There functions are not called anywhere within the framework scripts, and so their sequence is irrelevant unless you were doing something specifically with flexslider or roundabout. I’ll remove these in the next update.

    Like a hint one is supposed to do this, replace entire function if not happy with defaults.

    If you wanted to change the $deps, you wouldn’t need to replace the entire function. You could just filter the array.

    function my_framework_scripts( $scripts ){
    	$scripts = array( 'jquery', 'bootstrap', 'prettyphoto', 'superfish', 'themeblvd' );
    	return $scripts;
    }
    add_filter('themeblvd_framework_scripts', 'my_framework_scripts');

    And if you’re wanting to remove certain scripts you could de-register them from your own function, as well.

    #1576
    karlo
    Participant

    Cool – then I am not crazy, heh.

    Yes thanks for filter reminder, is put in for a reason. But I initially did not think so much and replaced entire function, has a !function so possible, but never felt quite right. Replace function to remove dependencies, hmm. I dont think I fully understood purpose of “global $themeblvd_framework_scripts;” but it make sense except default should not include more than necessary = not sliders. I will make use of filter as it is simpler which is a good feature with JS/CSS load. At least at some over the top point 🙂 – and keep eye on update.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.