Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single API URL for a chain of libraries. #34

Closed
nikhiljohn10 opened this issue Aug 5, 2020 · 1 comment
Closed

Single API URL for a chain of libraries. #34

nikhiljohn10 opened this issue Aug 5, 2020 · 1 comment

Comments

@nikhiljohn10
Copy link

Feature request

Feature description

Single API URL for a chain of libraries.

The same feature is implemented in Google fonts as it is given below:

<link href="https://fonts.googleapis.com/css2?family=Recursive:wght@400;700&family=Roboto:wght@300;400&display=swap" rel="stylesheet">

This can be a similar format for cdnjs API.

<link href="https://api.cdnjs.com/libraries/css?load=twitter-bootstrap@4.5.0:bootstrap.min.css;photoswipe@4.1.3:photoswipe.min.css,default-skin/default-skin.min.css;" rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'">

<script src="https://api.cdnjs.com/libraries/js?load=jquery@3.5.1:jquery.min.js;photoswipe@4.1.3:photoswipe.min.js,photoswipe-ui-default.min.js;" defer type="text/javascript">

When this request is received by the API server, query is parsed to create a JSON object. Using this object, server will retrieve all the specific libraries requested and concatenate all of them in the same order as it is requested.

The only restriction is the CSS & JS can not be mixed up in same request as it can not be loaded by the same HTML tag. Also, Images cannot be requested in the same way. But map files can be requested in a similar way in future versions if really needed.

How the feature is useful

This could decrease the request count. When all libraries needed at loaded in a single request, there will not be any blocking requests and it increases the web performance of the website as part of optimization.

@nikhiljohn10
Copy link
Author

This should not be a feature of API server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant