{"id":161563,"date":"2022-09-09T06:30:52","date_gmt":"2022-09-09T06:30:52","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/lightweight-js-snippet\/"},"modified":"2026-05-04T06:40:07","modified_gmt":"2026-05-04T06:40:07","slug":"lightweight-js-snippet","status":"publish","type":"plugin","link":"https:\/\/zul.wordpress.org\/plugins\/lightweight-js-snippet\/","author":8857345,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.4.1","stable_tag":"1.4.1","tested":"6.9.4","requires":"5.0","requires_php":"7.4","requires_plugins":null,"header_name":"Lightweight JS Snippet","header_author":"jonashjalmarsson","header_description":"Add scipt to a specific page or post.","assets_banners_color":"e3e6ee","last_updated":"2026-05-04 06:40:07","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/jonashjalmarsson.se\/help-me-out\/","header_plugin_uri":"https:\/\/wordpress.org\/plugins\/lightweight-js-snippet\/","header_author_uri":"https:\/\/jonashjalmarsson.se","rating":0,"author_block_rating":0,"active_installs":0,"downloads":1012,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.0":{"tag":"1.0","author":"jonas.hjalmarsson","date":"2022-09-09 06:30:25"},"1.1":{"tag":"1.1","author":"jonas.hjalmarsson","date":"2022-09-09 06:30:25"},"1.2":{"tag":"1.2","author":"jonas.hjalmarsson","date":"2022-10-07 08:00:13"},"1.4":{"tag":"1.4","author":"jonas.hjalmarsson","date":"2026-05-03 17:04:12"},"1.4.1":{"tag":"1.4.1","author":"jonas.hjalmarsson","date":"2026-05-04 06:40:07"}},"upgrade_notice":{"1.3":"<p>Sanitize and escape pass on the settings page and saved values. No functional changes.<\/p>","1.0":"<p>Initial release.<\/p>"},"ratings":[],"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":3521626,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.png":{"filename":"icon-256x256.png","revision":3521626,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-1544x500.jpg":{"filename":"banner-1544x500.jpg","revision":3521626,"resolution":"1544x500","location":"assets","locale":""},"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":3521626,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.jpg":{"filename":"banner-772x250.jpg","revision":3521626,"resolution":"772x250","location":"assets","locale":""},"banner-772x250.png":{"filename":"banner-772x250.png","revision":3521626,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0","1.1","1.2","1.4","1.4.1"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":3521626,"resolution":"1","location":"assets","locale":""}},"screenshots":{"1":"Settings page with code editor and post-ID list."},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[3195,3936,229,86,9309],"plugin_category":[59],"plugin_contributors":[202990],"plugin_business_model":[],"class_list":["post-161563","plugin","type-plugin","status-publish","hentry","plugin_tags-head","plugin_tags-inline","plugin_tags-javascript","plugin_tags-post","plugin_tags-snippet","plugin_category-utilities-and-tools","plugin_contributors-jonashjalmarsson","plugin_committers-jonashjalmarsson"],"banners":{"banner":"https:\/\/ps.w.org\/lightweight-js-snippet\/assets\/banner-772x250.png?rev=3521626","banner_2x":"https:\/\/ps.w.org\/lightweight-js-snippet\/assets\/banner-1544x500.png?rev=3521626","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/lightweight-js-snippet\/assets\/icon-128x128.png?rev=3521626","icon_2x":"https:\/\/ps.w.org\/lightweight-js-snippet\/assets\/icon-256x256.png?rev=3521626","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/lightweight-js-snippet\/assets\/screenshot-1.png?rev=3521626","caption":"Settings page with code editor and post-ID list."}],"raw_content":"<!--section=description-->\n<p>A minimal way to inject a single inline JavaScript snippet into the <code>&lt;head&gt;<\/code> of one or more specific posts, pages or products. You give it a comma-separated list of post IDs and the JS body \u2014 that is the entire surface area.<\/p>\n\n<p>The point is the absence of features. There is no per-post UI, no script library, no CDN selector, no \"fire on event\" toggle. If all you need is to drop a tracking pixel or a tiny script on three specific pages, you do not want a 2 MB plugin that wants to manage your whole site.<\/p>\n\n<p>Set it up under <strong>Settings \u2192 Lightweight JS snippet<\/strong>. The page provides a textarea for the JS (no <code>&lt;script&gt;<\/code> tags \u2014 those are added for you) and a comma-separated list of post IDs to load it on.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload <code>\/lightweight-js-snippet\/<\/code> to the <code>\/wp-content\/plugins\/<\/code> directory.<\/li>\n<li>Activate the plugin through the Plugins menu in WordPress.<\/li>\n<li>Go to <strong>Settings \u2192 Lightweight JS snippet<\/strong> and paste in your JS plus the post IDs.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id=\"where%20does%20the%20script%20run%3F\"><h3>Where does the script run?<\/h3><\/dt>\n<dd><p>It is printed inline in the <code>&lt;head&gt;<\/code> of the listed posts\/pages, only.<\/p><\/dd>\n<dt id=\"can%20i%20add%20%60%3Cscript%3E%60%20tags%3F\"><h3>Can I add `` tags?<\/h3><\/dt>\n<dd><p>No \u2014 they are added for you. Only paste the JS body.<\/p><\/dd>\n<dt id=\"does%20it%20support%20more%20than%20one%20page%3F\"><h3>Does it support more than one page?<\/h3><\/dt>\n<dd><p>Yes. Use a comma-separated list of post IDs. Search for the post name in the settings page to find the ID automatically.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.4.1<\/h4>\n\n<ul>\n<li>Fix empty <code>&lt;script id=\"jhljs-script\"&gt;<\/code> tag rendered on every page when no snippet was configured. Logic error (<code>||<\/code> where <code>&amp;&amp;<\/code> was meant) plus no early-return on empty options.<\/li>\n<li>Fix Settings link on the Plugins screen \u2014 previous filter targeted the wrong plugin basename, and the URL pointed at a non-existent menu slug. Both corrected.<\/li>\n<\/ul>\n\n<h4>1.4<\/h4>\n\n<ul>\n<li>Settings page now lets you pick target posts\/pages by typing their title \u2014 the \"comma-separated post IDs\" textbox is replaced with a chip-style picker. Two small REST endpoints (<code>jhljs\/v1\/posts<\/code>, <code>jhljs\/v1\/search<\/code>) gated to <code>manage_options<\/code> power the lookup and search.<\/li>\n<\/ul>\n\n<h4>1.3<\/h4>\n\n<ul>\n<li>Sanitize the post-id list and the JS snippet on save via <code>register_setting()<\/code> callbacks (digits\/commas\/whitespace for the IDs, <code>wp_kses<\/code> <code>'data'<\/code> for the script \u2014 same filter that was already applied on output).<\/li>\n<li>Escape every translated string in the settings UI (<code>_e()<\/code>\/<code>__()<\/code> \u2192 <code>esc_html_e()<\/code>\/<code>esc_html__()<\/code>) and use <code>esc_textarea()<\/code> for the snippet field.<\/li>\n<li>Add the missing <code>License<\/code>, <code>License URI<\/code> and <code>Text Domain<\/code> headers, fix the text-domain mismatches, and add an explicit version to <code>wp_enqueue_script()<\/code>.<\/li>\n<li>Bumped minimum PHP to 7.4. Tested up to WordPress 6.9.<\/li>\n<\/ul>\n\n<h4>1.2<\/h4>\n\n<ul>\n<li>Bugfix when escaping script.<\/li>\n<\/ul>\n\n<h4>1.1<\/h4>\n\n<ul>\n<li>Code editor added.<\/li>\n<li>Support for multiple ids.<\/li>\n<li>Securing plugin.<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>Initial release.<\/li>\n<\/ul>","raw_excerpt":"Add a small inline JavaScript snippet to one or more specific posts or pages, by post ID. No bloat, no front-end editor.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/161563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=161563"}],"author":[{"embeddable":true,"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/jonashjalmarsson"}],"wp:attachment":[{"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=161563"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=161563"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=161563"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=161563"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=161563"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/zul.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=161563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}