0

I want to know that is there any problem with importing all plugin styles including bootstrap into my working stylesheet.less and compile all of them as stylesheet.css instead of using wp_enqueue_style and then minify and compine all of them with cache plugins?

enter image description here

result is same (1 minified css) but want to know is there any standard that does not allow importing instead of enqueue?

Amino
  • 563
  • 1
  • 9
  • 26

1 Answers1

0

It depends on lot's of factors, but normally it would be better to enqueue one stylesheet.css if all the less files are being compiled into one file. Note that it is very imported that they are concatenated into one file because from a page speed standpoint, @import from a CSS file should almost never be used, as it can prevent stylesheets from being downloaded concurrently.

Another difference is compiling is usually happening locally before you upload to the server, so it is quite obvious that this will be faster compared to loading the cache plugins etc. that will do the same for you.

That being said if you have a server running http/2 downloading a lot of tiny style sheets won’t matter, HTTP requests are cheap in the world of HTTP/2. So organizing your css-files according to the page-templates on which they will be used will be far better. You can then serve up only the code that the visitor needs. Basically what I'm trying to say is that you may not need any cache plugins if you are running on a http/2 server, but it will require that the files are compiled to css before uploading to the server.

There might be something more people want to add, but I think this should cover your question.

Community
  • 1
  • 1
lassemt
  • 164
  • 1
  • 11
  • 1
    Btw, when I ask other WP developers why they are using cache/compiler plugins instead of compiling locally they say it is mostly because of laziness. Just wanted to share this personal experience because it's a bit funny. – lassemt Aug 24 '16 at 09:06
  • Haha, the result (compiled css file) will not contain @import it will be 1 minifed css file (production mode) and if developer need to add something, need to edit LESS instead of css. thank you for your answer. – Amino Aug 24 '16 at 10:41
  • 1
    @Amino Yes, then you should just be fine enqueueing the compiled css file :) – lassemt Aug 24 '16 at 11:22