0

Is it possible to somehow automatically download all CSS files under a directory and its subdirectory without providing actual css file names

I have many css files, more specifically 12. All are under a directory styles and its subdirectories (only 1 level of subdirectories).

Following syntax doesn’t work to load all css

<link href='https://xxx/styles/*/*.css' rel='stylesheet' type='text/css’/>

Is there a workaround to load all css or I’ve to add 12 lines in HTML to download these.

NOTE: I’m ok to tradeoff performance for maintenance, and to have 12 different request instead of one. Its my personal webite and files are hosted from ny GitHub Pages.So I can not do any post processing to convert all file into one.

1 Answer 1

1

If you do not mind having multiple requests to the server, you can create a main CSS file and inside it add @import to the other files.

main.css

@import url('/css/file_one.css');
@import url('/css/file_two.css');
@import url('/css/dir/file_one.css');

And in your HTML file

<link rel="stylesheet" href="/css/main.css" />

Just do not remember if in import need to add the complete URL.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.