0

I want to move theme stylesheets from head section to body section, for example:

<link rel='stylesheet' id='flatsome-main-css-css'
      href='//www.mysite.com/wp-content/themes/flatsome/css/foundation.css' 
      type='text/css' media='all' />

I want to move this link to the body section, but don't know how.

Håken Lid
  • 22,318
  • 9
  • 52
  • 67
zed
  • 143
  • 9

1 Answers1

0

Several ways to do this, for example:

  1. As simple as this:

<link href=".../yourstylesheet.css" rel="stylesheet" type="text/css" />

Mind the difference, you don't put rel="stylesheet/css", just rel="stylesheet"

  1. JS way:

loadCSS = function(href) {

  var cssLink = $("<link>");
  $("head").append(cssLink); //IE hack: append before setting href

  cssLink.attr({
    rel:  "stylesheet",
    type: "text/css",
    href: href
  });

};

Usage:

loadCSS("loadCSS(".../yourstylesheet.css");");

Credits: https://stackoverflow.com/a/13556622/6134447

But I second Dadani's question: why would you do that? :)

Community
  • 1
  • 1
bugnumber9
  • 451
  • 1
  • 4
  • 16