[wp-trac] [WordPress Trac] #48654: Consider a solution/endpoint to lazy-load scripts and styles
WordPress Trac
noreply at wordpress.org
Wed Nov 20 15:15:39 UTC 2019
#48654: Consider a solution/endpoint to lazy-load scripts and styles
-------------------------------------------------+-------------------------
Reporter: youknowriad | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: REST API | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch dev-feedback needs-unit- | Focuses:
tests | javascript, rest-api
-------------------------------------------------+-------------------------
Changes (by spacedmonkey):
* keywords: => has-patch dev-feedback needs-unit-tests
* version: => 4.7
Comment:
In [https://core.trac.wordpress.org/attachment/ticket/48654/48654.diff
48654.diff] I made a first pass at the new REST APIs. This patch, does
nothing to handle the security issues related to show on register scripts
and styles. Just output the scripts and styles in a usable format.
This patch adds the following APIs.
/wp-json/wp/v2/scripts
/wp-json/wp/v2/styles
Both of these apis have the followings options.
/wp-json/wp/v2/scripts - List all registered scripts
/wp-json/wp/v2/scripts/<handle> - List a single script by handle.
wp/v2/scripts/?dependency=<handle> - List all dependencies of a given
handle. This includes the handle itself and recursive dependencies.
{{{
{
handle: "jquery-ui-core",
src: "/wp-includes/js/jquery/ui/core.min.js",
deps: [
"jquery"
],
ver: "1.11.4",
args: 1,
extra: [ ],
textdomain: null,
translations_path: null,
url: "http://src.wordpress-develop.test/wp-
includes/js/jquery/ui/core.min.js?ver=1.11.4",
_links: {
self: [
{
href: "http://src.wordpress-develop.test/wp-json/wp/v2/scripts
/jquery-ui-core"
}
],
collection: [
{
href: "http://src.wordpress-develop.test/wp-json/wp/v2/scripts"
}
],
deps: [
{
href: "http://src.wordpress-develop.test/wp-
json/wp/v2/scripts/?dependency=jquery-ui-core"
}
]
}
},
}}}
Does this look like a work format for you @youknowriad
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48654#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list