Jump to content

Archived

This topic is now archived and is closed to further replies.

paulzz1

Unnecessary assets loading in head

Recommended Posts

paulzz1

Hi

 

After some experimenting, I deleted most of the sections from a template and looked at the code.

 

There was still a link to Open Sans which I had replaced with Droid Sans

 

<link rel="stylesheet" id="open-sans-css" href="//fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&amp;subset=latin%2Clatin-ext&amp;ver=3.8.1" type="text/css" media="all">

 

Plus a link to a Hero Nav stylesheet that I'd removed.

 

There was this also which I don't know the use of...

 

<meta property="pl-share-desc" content="Home Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum [...]">

 

And, finally, why does so much JS get loaded in the head?

 

I had published and disabled DMS editor panel.

 

I'm using DMS 2.03

 

Thanks

 

Paul

 

Share this post


Link to post
Share on other sites
paulzz1

Hi

 

Any response? I've tried a couple of new sites and it happens on each - loading Open Sans fonts from Google that I don't need.

 

Thanks

 

Paul

Share this post


Link to post
Share on other sites
greenfly

cam you enable debug on these sites and provide links so we can take a look please?


The answer to many issues can be found by searching in the forum before posting as someone else  may very well have had the same problem before you have.  Also, reading the documentation can help you gain a good understanding of how everything works. 

 

Please do not send me private messages. Occam's razor - The principle states "Keep things simple!"

Share this post


Link to post
Share on other sites
paulzz1

I've just noticed that the headers for the widgets are still set to Open Sans even though I've specified Georgia in the main and header typography panels. This will be why there's a link to the font in the head.

 

Here're two simple blogs with this in the head even though the fonts have been set to Georgia.

 

<link rel='stylesheet' id='open-sans-css' href='//fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&#038;subset=latin%2Clatin-ext&#038;ver=3.9' type='text/css' media='all' />

 

 

http://richardelsy.com

http://aversedperson.com

 

In Pagelines Framework there was more granular type selection with, as I remember, sub-heading and widget heading control. I know I can specify what fonts I want in some custom CSS but what if I don't want to use Open Sans and have to make http requests that are unnecessary?

Share this post


Link to post
Share on other sites
Danny

DMS buttons use the those fonts by default and regardless of what fonts you select in the Typography settings, thats the likely reason as to why they're loaded.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
paulzz1

That's all well and good but it's an overhead that I'd like to remove. WP and DMS already have LOADS of http requests for scripts and styles. It'd be good to have control over what gets loaded — especially if it's not needed for the site.

Share this post


Link to post
Share on other sites
Danny

You can follow the guide here to remove any scripts you like - http://codex.wordpress.org/Function_Reference/wp_dequeue_script

 

Please be aware that by doing so, we will be unable to provide any assistance if you encounter any issues.

 

However, here is an example, this gets added to your child themes functions.php file, this will remove the fitvids.js file.

 

add_action('wp_enqueue_scripts', 'deregister_pl_fitvids', 100);
function deregister_pl_fitvids() {
wp_dequeue_script('pagelines-fitvids');
}

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
paulzz1

Exactly — what I have to do is potentially break the site just to remove something I didn't want in it in the first place. Surely there's a more robust way to control the fonts / loading of unnecessary assets?

Share this post


Link to post
Share on other sites
Danny

I have explained above that the fonts you have linked are used for buttons, so they're not unnecessary assets.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
paulzz1

But, if I don't use the buttons (although I'm entirely sure what this means) and don't want that font for the widget headers, shouldn't I be able to remove it?

Share this post


Link to post
Share on other sites
Simon

Carrying on from what Danny posted earlier:

 

https://gist.github.com/Pross/11258263

Share this post


Link to post
Share on other sites
paulzz1

Yeah, I'm getting the fix but why is it there in the first place? Am I being stupid and/or unreasonable to think that only the things I want added are by default? And, if I want to remove them I don't have to resort to, slightly, flimsy hacks?

Share this post


Link to post
Share on other sites
Simon

Its there because the default font is Open Sans.

 

How is my code flimsy?

Share this post


Link to post
Share on other sites
paulzz1

That's my problem! Why is it default? What is it for? Why should I have to use assets — in this case a font — that I don't want? Something that adds to the http requests, slows the site and damages performance and, therefore, SEO?

If I wanted that font, I should have the option to include or remove it. If it's a default font for Widgets etc, I (already said this above) should be able to either replace it or let the components inherit the default fonts that I chose.

Sorry, I wasn't meaning to criticise your code. Just the reason for having to use it in the first place.

Share this post


Link to post
Share on other sites
Simon

Its the default in the font stack.

 

@defaultFont:         "Open Sans", "Helvetica Neue", "Helvetica", Arial, serif;

 

If you don't want to use it then simply dequeue it.

Share this post


Link to post
Share on other sites
paulzz1

Hi

Dequeuing seemed to work but, after moving to DMS 2.1, and having the following in my functions file:

 

add_action('wp_enqueue_scripts', 'deregister_pl_opensans', 100);
function deregister_pl_opensans() {
wp_dequeue_style('open-sans');
}
 
It is still loaded.
 
 
Any ideas?

Share this post


Link to post
Share on other sites
paulzz1

Sorry! Ignore. My cache had messed up.

all sorted.

Thanks

Share this post


Link to post
Share on other sites
Danny

Thanks for informing us the issue has been resolved.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
paulzz1

Back again! Just upgraded to 2.1.1 and something's amiss.

 

The DMS frontend editor hangs If I add the suggested code:

 

add_action('wp_enqueue_scripts', 'deregister_pl_fitvids', 100);
function deregister_pl_fitvids() {
wp_dequeue_script('pagelines-fitvids');
}
I'm not using anything that requires that JS.

Share this post


Link to post
Share on other sites
Simon

You should be using this:

 

add_action('wp_print_scripts', 'deregister_pl_fitvids' );
function deregister_pl_fitvids() {
if( ! pl_draft_mode() )
  wp_dequeue_script('pagelines-fitvids');
}

Share this post


Link to post
Share on other sites
paulzz1

OK. Thanks. Will give it a shot.

Any tips on dequeuing styles at the same time? For example, I don't want Open Sans to load, although it does by default.

Share this post


Link to post
Share on other sites
Simon

That was already mentioned earlier in this topic:

wp_dequeue_style('open-sans');

Share this post


Link to post
Share on other sites
paulzz1

As before? Just add:

 

wp_dequeue_style('open-sans');

 

to the code you provided?

 

Can I continue to list scripts and styles I want dequeued in the same way?

Share this post


Link to post
Share on other sites
Simon

As before? Just add:

 

wp_dequeue_style('open-sans');

 

to the code you provided?

 

Can I continue to list scripts and styles I want dequeued in the same way?

Yes.

Share this post


Link to post
Share on other sites

  • Similar Content

    • Lisa Haran
      By Lisa Haran+
      Hi 
      I have a map here http://www.iloveoffset.com/maps/
      I want to add several pointer locations to the map, but when I do they do not appear.
      On this map there are 2 pointer locations and as you can there is only one visible.
      Earlier today I added 7 and could only see 4 so there is something odd going on.
      My theme is up to date
    • clj182
      By clj182+
      Hello,
      I've been having trouble unlocking the template section for past couple of weeks. When I try clicking nothing happens. 
      I've deleted my custom css and removed plugins. Im down to having only the following plugins:
      Akismet
      Contact Form 7
      DMS Professional Tools
      Pagelines Updater
      WooCommerce
      It was working fine before i have no idea what's going on with it.
    • flourishdesignstudio
      By flourishdesignstudio+
      My DMS 2 site http://www.heart-stone.com/ will not save any new custom css... I can still edit templates and publish those but any custom css that I enter never saves.
      All WP files, themes, and plugins are up to date. 
      Any thought about what might be causing this?
    • flourishdesignstudio
      By flourishdesignstudio+
      Is there a way to edit the custom CSS via FTP? I know I can edit the custom code in the Chrome editor but is there a file path I can use to find and edit the CSS directly from our FTP?
      Thanks in advance for the help!
    • nizami
      By nizami+
      Using navbar section with correctly configured WP menu to display main navigation at https://elenaangel.com. 
      All fine in desktop viewport. Menu displays twice in hamburger mode. How to fix this please? 

×