• Resolved eheine

    (@eheine)


    I tried to write some custom css in my themes styles.css to overwrite the defaults that come with the plugin. But nothing I do seems to change anything. So I eventually used my brain and inspected the source. Seems that the stylesheet for this plugin is loading in the bottom body of the page rather than in the head tag. Here is the test site. Most of the other plugins load in the head along with my theme styles.

    https://www.ads-software.com/plugins/food-and-drink-menu/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter eheine

    (@eheine)

    Nevermind…I found some other posts about css loading and many suggested just having a separate css for plugins included with my theme that loads after everything else. I will try that first.

    Hi eheine,

    The styles don’t load in the head because the styles are only loaded on pages where the menu is rendered. In most cases, that can’t be determined until too late during the page load to load the styles in the head.

    Since most people will only need the menu styles on 1 or 2 pages of their site, this prevents users’ browsers from making an extra round trip for a useless stylesheet.

    However, I’ve used CSS styles with very low specificity so that they can be overwritten by using a rule with more specifity. If you add an attribute selector like [id^="fdm-menu-"] in front of your CSS rules, you should be able to override any of the other styles that are set. For instance, if you wanted to target the price wrapper, .fdm-item-price-wrapper, you’d use [id^="fdm-menu-"] .fdm-item-price-wrapper.

    If you’re pretty confident you’ll only ever have one menu on a page at once, you can use the slighly more performant #fdm-menu-1 selector in place of [id^="fdm-menu-"].

    If you have any specific rules you can’t get working, post them here and I can probably give you something that will work.

    You can do that, but I always recommend cutting down on the number of different CSS files retrieved where possible. Although the files themselves may not be a lot to download, on slow connections (like 3g mobiles) simply making an extra round trip to the server to retrieve an extra file can add to your overall load time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘CSS loading in the body rather than the head’ is closed to new replies.