Tag Info

New answers tagged

1

Before starting answer I have to say that regarding this topic css and js are not the same. Reason is simple: while adding js to the body of the page (in footer) is a common and valid way to act, css need to be in the <head> section of the page: even if majority of browsers can proper render css in page boy, it is not valid HTML code. When a ...


0

One of the parameters of the enqueue_script function is the $in_footer take a look of the function usage arguments: wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ) So to add your script(or css) to the header instead of footer you should try something like: wp_enqueue_script('tooltipster', urlto.'/jsjquery.tooltipster.min.js', array( ...


2

It seems that you need to add styles and scripts to a single post. The best way to achieve this is to make use of the conditional tag is_single() With that you target specific single posts or all single posts. Styles should always be loaded in the header. <link> tags outside the <head></head> tags are invalid HTML. You should check this ...


0

I cant figure out where to hook so that A. The $post is set up and 2. the style and script get included in the header. Those two things are mutually exclusive. The global $post won't be set up until the main Loop starts, which is well after the header has already been output. Edit for comments clarification: Again, the actual global $post isn't set ...


0

i finally know why this code not work. as menstioned by Jorn Lund in the comment that jQuery(document).ready() will fail when script loaded async ( i still dont know is my code load async) but with in mind i change from jQuery(document).ready() to self execution function (function($){ alert("hello"); })(jQuery); and the code work very well on ...


0

I found that it was better for me to use the latest jQuery version (which WordPress loads by default) and to treat the incompatibility issue by modifying the JS plugin files that were incompatible with the latest jQuery version. Note: The reason I chose this solution is because in most cases, JS plugin incompatibility with newer jQuery versions is a result ...


2

Today I needed to do more or less same thing, ending up on an alternative solution, that I want to share in case it can be useful for someone. I wrote a custom class extending WP_Script, something like this: class GM_Scripts extends WP_Scripts { static function buildFromWp( WP_Scripts $scripts ) { $class = get_called_class(); $obj = ...


3

As @pieter-goosen and @birgire in other answer and comments, W3C specs do not allow css in footer, quote from specs page linked: A link element must have a rel attribute. If the rel attribute is used, the element is restricted to the head element. Aside from that, you should note that when you add css in footer, when someone opens your page it ...


0

The page load speed is probably beeing affected by other requests. Like Pieter Goosen said you are probably not going to notice the difference. To prove that: Remove those scripts requests and check the difference on the page load. With the Firefox or Google Chrome Developer Tools you can easily check all the requests, and see which ones are slowing down ...


3

I don't know what your exact reason is for this, but you should scrap the idea of moving styles to the footer. If you though of a gain in speed, you might gain a unnoticable amount, if any, but that will be at the cost of other bigger things. Styles should always be added inside the <head></head> tag. The reason is that <style> tags ...


4

From your comment above I read This is one of the reason why i am looking for a way to say to wordpress: "hey, i added those js files, dont worry". This is whole purpose of this question I think is perfectly fair, I +1ed your Q but the problem is that way does not exists, or better does not exists a clean, canonical way. How To first of all you ...


1

Why don't you just de-Register those handles to 6 different files, and re-register those handles to one combined file? I think if you have 6 different handles, pointing to one file, WordPress will enque this file just once. So you can guarantee that your dependencies dont break up. Is this an possible solution for you?


1

In my honest opinion, I would not do that. PRO'S and CON's PRO'S There are really not any pro's here, except for having a couple of files fewer. I don't even think that you are going to gain any significant load time at all combining these files CON'S There are many concerns here You should not make direct changes to buddypress files. You will loose ...



Top 50 recent answers are included