<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JavaScript Archives - Creatronix</title>
	<atom:link href="https://creatronix.de/category/software-engineering/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>https://creatronix.de/category/software-engineering/javascript/</link>
	<description>My adventures in code &#38; business</description>
	<lastBuildDate>Tue, 14 Oct 2025 07:39:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>How to use Greasemonkey to make your life easier</title>
		<link>https://creatronix.de/how-to-use-greasemonkey-to-make-your-life-easier/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Thu, 17 Feb 2022 07:43:48 +0000</pubDate>
				<category><![CDATA[DevOps & Automation]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://creatronix.de/?p=5115</guid>

					<description><![CDATA[<p>Motivation Sometimes you encounter websites which seem to have time traveled from 1999. No responsive UI, no widgets, just plain html input fields and selects. Time to improve these sites 🙂 Greasemonkey overview Greasemonkey is a browser plugin which lets you inject client-side JavaScript into the webpage just as the developer could have intended to&#8230;</p>
<p>The post <a href="https://creatronix.de/how-to-use-greasemonkey-to-make-your-life-easier/">How to use Greasemonkey to make your life easier</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Motivation</h2>
<p>Sometimes you encounter websites which seem to have time traveled from 1999. No responsive UI, no widgets, just plain html input fields and selects.</p>
<p>Time to improve these sites 🙂</p>
<h2>Greasemonkey overview</h2>
<p>Greasemonkey is a browser plugin which lets you inject client-side JavaScript into the webpage just as the developer could have intended to do.</p>
<p><a href="https://addons.mozilla.org/de/firefox/addon/greasemonkey/">GM for firefox</a></p>
<p>If you use Google Chrome you can use the <a href="https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo">Tampermonkey</a> extension.</p>
<p>Now you can manipulate the DOM to make the page look more appealing and function better.</p>
<p>&nbsp;</p>
<h2>Hello <del>World</del> Greasemonkey</h2>
<p>Let&#8217;s start with a simple script:</p>
<pre>// ==UserScript==
// @name hello_greasemonkey
// @namespace https://creatronix.de
// @description prints "Hello Greasemonkey" to the console
// @include https://creatronix.de*
// @version 1
// ==/UserScript== 
console.log("Hello Greasemonkey");
</pre>
<p>This script does nothing more than printing a string to the console</p>
<p>Ctrl + Shift + J opens the Browser console in Firefox.</p>
<p>Hint: If you don&#8217;t see the console output you have to activate &#8220;Show Content messages&#8221; in the gear menu of the browser console.</p>
<p>The @include statement ties the script to a specific URL. The wildcard * can be used to indicate all sub-URLs shall be included as well.</p>
<p>But wait &#8211; there is more:</p>
<h2>Add jQuery UI Datepicker</h2>
<p>I&#8217;ve had a page where the date input where just plain input fields.</p>
<p>With the following script I&#8217;ve added a nice date picker widget.</p>
<p>For that purpose you can use jQuery and jQuery UI.</p>
<p>With the @require you can use a CDN to import the needed libraries.</p>
<p>&nbsp;</p>
<pre>// ==UserScript==
// @name add_calendar_widget
// @namespace creatronix
// @description adds an jQuery-UI calendar to date fields
// @include &lt;the_site_to_insert_the_script&gt;
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @require https://code.jquery.com/ui/1.13.1/jquery-ui.min.js
// @version 1

// ==/UserScript==

$(document).ready(function(){
  console.log("script works");
  $( 'input[name="from"]' ).datepicker({ firstDay: 1, dateFormat: 'dd.mm.yy' });
  $( 'input[name="until"]' ).datepicker({ firstDay: 1, dateFormat: 'dd.mm.yy' });
  $("#ui-datepicker-div").css({'background-color':'white'});
}</pre>
<p>The post <a href="https://creatronix.de/how-to-use-greasemonkey-to-make-your-life-easier/">How to use Greasemonkey to make your life easier</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>JavaScript modules</title>
		<link>https://creatronix.de/javascript-modules/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Tue, 12 May 2020 09:07:31 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[snippet]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=3265</guid>

					<description><![CDATA[<p>&#60;head&#62; &#60;script src="../js/constants.js" type="module"&#62;&#60;/script&#62; &#60;script src="../js/script.js" type="module"&#62;&#60;/script&#62; &#60;/head&#62; constants.js export const projects = [ "Project-A", "Project-B", "Project-C", ]; script.js import {projects} from "./constants.js";</p>
<p>The post <a href="https://creatronix.de/javascript-modules/">JavaScript modules</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<pre>&lt;head&gt;
    &lt;script src="../js/constants.js" <strong>type="module"</strong>&gt;&lt;/script&gt;
    &lt;script src="../js/script.js" <strong>type="module"</strong>&gt;&lt;/script&gt;
&lt;/head&gt;</pre>
<p>constants.js</p>
<pre>export const projects = [
  "Project-A",
  "Project-B",
  "Project-C",
];</pre>
<p>script.js</p>
<pre>import {projects} from "./constants.js";</pre>
<p>The post <a href="https://creatronix.de/javascript-modules/">JavaScript modules</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Calculator for Resistor Values</title>
		<link>https://creatronix.de/calculator-for-resistor-values/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Fri, 13 Sep 2019 14:13:00 +0000</pubDate>
				<category><![CDATA[Electronics & IOT]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=2891</guid>

					<description><![CDATA[<p>Calculator for 4 rings 1. Ring 2. Ring 3. Ring 4. Ring Value Tolerance brownredorangeyellowgreenbluepurplegreywhite blackbrownredorangeyellowgreenbluepurplegreywhite blackbrownredorangeyellowgreenbluepurplegoldsilver brownredgreenbluepurplegoldsilver 0Ω 0% Calculator for 5 rings 1. Ring 2. Ring 3. Ring 4. Ring 5. Ring Value Tolerance brownredorangeyellowgreenbluepurplegreywhite blackbrownredorangeyellowgreenbluepurplegreywhite blackbrownredorangeyellowgreenbluepurplegreywhite blackbrownredorangeyellowgreenbluepurplegoldsilver brownredgreenbluepurplegoldsilver 0Ω 0%</p>
<p>The post <a href="https://creatronix.de/calculator-for-resistor-values/">Calculator for Resistor Values</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Calculator for 4 rings</h2>
<table>
<tbody>
<tr>
<td>1. Ring</td>
<td>2. Ring</td>
<td>3. Ring</td>
<td>4. Ring</td>
<td>Value</td>
<td>Tolerance</td>
</tr>
<tr>
<td><select id="ring_1_4r"><option style="background-color: saddlebrown;" value="1">brown</option><option style="background-color: red;" value="2">red</option><option style="background-color: orange;" value="3">orange</option><option style="background-color: yellow;" value="4">yellow</option><option style="background-color: green;" value="5">green</option><option style="background-color: blue;" value="6">blue</option><option style="background-color: purple;" value="7">purple</option><option style="background-color: grey;" value="8">grey</option><option style="background-color: white;" value="9">white</option></select></td>
<td><select id="ring_2_4r"><option style="background-color: black;" value="0">black</option><option style="background-color: saddlebrown;" value="1">brown</option><option style="background-color: red;" value="2">red</option><option style="background-color: orange;" value="3">orange</option><option style="background-color: yellow;" value="4">yellow</option><option style="background-color: green;" value="5">green</option><option style="background-color: blue;" value="6">blue</option><option style="background-color: purple;" value="7">purple</option><option style="background-color: grey;" value="8">grey</option><option style="background-color: white;" value="9">white</option></select></td>
<td><select id="ring_3_4r"><option style="background-color: black;" value="1">black</option><option style="background-color: saddlebrown;" value="10">brown</option><option style="background-color: red;" value="100">red</option><option style="background-color: orange;" value="1000">orange</option><option style="background-color: yellow;" value="10000">yellow</option><option style="background-color: green;" value="100000">green</option><option style="background-color: blue;" value="1000000">blue</option><option style="background-color: purple;" value="10000000">purple</option><option style="background-color: gold;" value="0.1">gold</option><option style="background-color: silver;" value="0.01">silver</option></select></td>
<td><select id="ring_4_4r"><option style="background-color: saddlebrown;" value="1">brown</option><option style="background-color: red;" value="2">red</option><option style="background-color: green;" value="0.5">green</option><option style="background-color: blue;" value="0.25">blue</option><option style="background-color: purple;" value="0.1">purple</option><option style="background-color: gold;" value="5">gold</option><option style="background-color: silver;" value="10">silver</option></select></td>
<td><span id="result_4r">0</span>Ω</td>
<td><span id="tolerance_4r">0</span>%</td>
</tr>
</tbody>
</table>
<h2>Calculator for 5 rings</h2>
<table>
<tbody>
<tr>
<td>1. Ring</td>
<td>2. Ring</td>
<td>3. Ring</td>
<td>4. Ring</td>
<td>5. Ring</td>
<td>Value</td>
<td>Tolerance</td>
</tr>
<tr>
<td><select id="ring_1_5r"><option style="background-color: saddlebrown;" value="1">brown</option><option style="background-color: red;" value="2">red</option><option style="background-color: orange;" value="3">orange</option><option style="background-color: yellow;" value="4">yellow</option><option style="background-color: green;" value="5">green</option><option style="background-color: blue;" value="6">blue</option><option style="background-color: purple;" value="7">purple</option><option style="background-color: grey;" value="8">grey</option><option style="background-color: white;" value="9">white</option></select></td>
<td><select id="ring_2_5r"><option style="background-color: black;" value="0">black</option><option style="background-color: saddlebrown;" value="1">brown</option><option style="background-color: red;" value="2">red</option><option style="background-color: orange;" value="3">orange</option><option style="background-color: yellow;" value="4">yellow</option><option style="background-color: green;" value="5">green</option><option style="background-color: blue;" value="6">blue</option><option style="background-color: purple;" value="7">purple</option><option style="background-color: grey;" value="8">grey</option><option style="background-color: white;" value="9">white</option></select></td>
<td><select id="ring_3_5r"><option style="background-color: black;" value="0">black</option><option style="background-color: saddlebrown;" value="1">brown</option><option style="background-color: red;" value="2">red</option><option style="background-color: orange;" value="3">orange</option><option style="background-color: yellow;" value="4">yellow</option><option style="background-color: green;" value="5">green</option><option style="background-color: blue;" value="6">blue</option><option style="background-color: purple;" value="7">purple</option><option style="background-color: grey;" value="8">grey</option><option style="background-color: white;" value="9">white</option></select></td>
<td><select id="ring_4_5r"><option style="background-color: black;" value="1">black</option><option style="background-color: saddlebrown;" value="10">brown</option><option style="background-color: red;" value="100">red</option><option style="background-color: orange;" value="1000">orange</option><option style="background-color: yellow;" value="10000">yellow</option><option style="background-color: green;" value="100000">green</option><option style="background-color: blue;" value="1000000">blue</option><option style="background-color: purple;" value="10000000">purple</option><option style="background-color: gold;" value="0.1">gold</option><option style="background-color: silver;" value="0.01">silver</option></select></td>
<td><select id="ring_5_5r"><option style="background-color: saddlebrown;" value="1">brown</option><option style="background-color: red;" value="2">red</option><option style="background-color: green;" value="0.5">green</option><option style="background-color: blue;" value="0.25">blue</option><option style="background-color: purple;" value="0.1">purple</option><option style="background-color: gold;" value="5">gold</option><option style="background-color: silver;" value="10">silver</option></select></td>
<td><span id="result_5r">0</span>Ω</td>
<td><span id="tolerance_5r">0</span>%</td>
</tr>
</tbody>
</table>
<p><script type="application/javascript">
    jQuery(document).ready(function ($) {
        function calculateResistorValue4() {
            let ring_1 = parseInt($("#ring_1_4r").val());
            let ring_2 = parseInt($("#ring_2_4r").val());
            let ring_3 = parseFloat($("#ring_3_4r").val());
            var resistorValue = (ring_1 * 10 + ring_2) * ring_3;
            if (resistorValue >= 1000000) {
                resistorValue = resistorValue / 1000000.0;
                resistorValue = resistorValue.toFixed(2) + "M"
            }
            if (resistorValue >= 1000) {
                resistorValue = resistorValue / 1000.0;
                resistorValue = resistorValue.toFixed(2) + "k";
            }
            $("#result_4r").text(resistorValue);
        }
 function setTolerance4(){
            let ring_4 = parseFloat($("#ring_4_4r").val());
            $("#tolerance_4r").text(ring_4);
        }
        calculateResistorValue4();
        setTolerance4();
        $("#ring_1_4r").on("change", function () {
            calculateResistorValue4();
        });
        $("#ring_2_4r").on("change", function () {
            calculateResistorValue4();
        });
        $("#ring_3_4r").on("change", function () {
            calculateResistorValue4();
        });
        $("#ring_4_4r").on("change", function () {
            setTolerance4();
        });
        function calculateResistorValue5() {
            let ring_1 = parseInt($("#ring_1_5r").val());
            let ring_2 = parseInt($("#ring_2_5r").val());
            let ring_3 = parseFloat($("#ring_3_5r").val());
            let ring_4 = parseFloat($("#ring_4_5r").val());
            var resistorValue = ((ring_1 * 10 + ring_2) * 10 + ring_3) * ring_4;
            if (resistorValue >= 1000000) {
                resistorValue = resistorValue / 1000000.0;
                resistorValue = resistorValue.toFixed(2) + "M"
            }
            if (resistorValue >= 1000) {
                resistorValue = resistorValue / 1000.0;
                resistorValue = resistorValue.toFixed(2) + "k";
            }
            $("#result_5r").text(resistorValue);
        }
        function setTolerance5(){
            let ring_4 = parseFloat($("#ring_5_5r").val());
            $("#tolerance_5r").text(ring_4);
        }
        calculateResistorValue5();
        setTolerance5();
        $("#ring_1_5r").on("change", function () {
            calculateResistorValue5();
        });
        $("#ring_2_5r").on("change", function () {
            calculateResistorValue5();
        });
        $("#ring_3_5r").on("change", function () {
            calculateResistorValue5();
        });
        $("#ring_4_5r").on("change", function () {
            calculateResistorValue5();
        });
        $("#ring_5_5r").on("change", function () {
            setTolerance5();
        });
    });
</script></p>
<p>The post <a href="https://creatronix.de/calculator-for-resistor-values/">Calculator for Resistor Values</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Invalid Host Header with npm run server</title>
		<link>https://creatronix.de/invalid-host-header-with-npm-run-server/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Fri, 09 Aug 2019 08:47:32 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=2862</guid>

					<description><![CDATA[<p>I got an &#8220;Invalid Host Header&#8221; error when running a VueJs app on a linux machine with npm run serve To work around this you can put the following code into you vue.config.js file: module.exports = { // options... devServer: { disableHostCheck: true, } }</p>
<p>The post <a href="https://creatronix.de/invalid-host-header-with-npm-run-server/">Invalid Host Header with npm run server</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="alignnone size-large wp-image-3856" src="https://creatronix.de/wp-content/uploads/2021/10/img_6140-1024x768.jpg" alt="" width="525" height="394" srcset="https://creatronix.de/wp-content/uploads/2021/10/img_6140-1024x768.jpg 1024w, https://creatronix.de/wp-content/uploads/2021/10/img_6140-300x225.jpg 300w, https://creatronix.de/wp-content/uploads/2021/10/img_6140-768x576.jpg 768w, https://creatronix.de/wp-content/uploads/2021/10/img_6140-1536x1152.jpg 1536w, https://creatronix.de/wp-content/uploads/2021/10/img_6140-2048x1536.jpg 2048w" sizes="(max-width: 525px) 100vw, 525px" /></p>
<p>I got an &#8220;Invalid Host Header&#8221; error when running a VueJs app on a linux machine with</p>
<pre>npm run serve</pre>
<p>To work around this you can put the following code into you vue.config.js file:</p>
<pre>module.exports = {
    // options...
    devServer: {
        disableHostCheck: true,
    }
}</pre>
<p>The post <a href="https://creatronix.de/invalid-host-header-with-npm-run-server/">Invalid Host Header with npm run server</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ES6: var vs let vs const</title>
		<link>https://creatronix.de/es6-var-vs-let-vs-const/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Fri, 18 Aug 2017 19:57:49 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ES6]]></category>
		<category><![CDATA[javascript]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=988</guid>

					<description><![CDATA[<p>Dealing with KnockoutJS I came across some newer features of the JavaScript language ES6 TL;DR: don&#8217;t use var anymore when You declare variables. Some examples: As You can see a variable declared with the var keyword is visible outside its enclosing scope. Most of the time it&#8217;s not what You want. When You enable ES6&#8230;</p>
<p>The post <a href="https://creatronix.de/es6-var-vs-let-vs-const/">ES6: var vs let vs const</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Dealing with KnockoutJS I came across some newer features of the JavaScript language ES6</p>
<p>TL;DR: don&#8217;t use <strong>var</strong> anymore when You declare variables.</p>
<p>Some examples:</p>
<p><span id="more-988"></span><img decoding="async" class="alignnone size-full wp-image-996" src="https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.42.41.png" alt="" width="399" height="481" srcset="https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.42.41.png 399w, https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.42.41-249x300.png 249w" sizes="(max-width: 399px) 100vw, 399px" /></p>
<p>As You can see a variable declared with the <strong>var</strong> keyword is visible outside its enclosing scope. Most of the time it&#8217;s not what You want.</p>
<p>When You enable ES6 support in PyCharm it already warns You if You use <strong>var:</strong></p>
<p><img decoding="async" class="alignnone size-full wp-image-997" src="https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.42.56.png" alt="" width="521" height="182" srcset="https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.42.56.png 521w, https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.42.56-300x105.png 300w" sizes="(max-width: 521px) 100vw, 521px" /></p>
<p>To declared a variable which is on visible in its scope You can either use let or const.</p>
<p><img decoding="async" class="alignnone size-full wp-image-998" src="https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.53.04.png" alt="" width="480" height="180" srcset="https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.53.04.png 480w, https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.53.04-300x113.png 300w" sizes="(max-width: 480px) 100vw, 480px" /></p>
<p><strong>Let</strong> lets your variable be mutable so you can use it in a loop as counter. If You want to guarantee even more that one variable is used for one concept only You can use <strong>const</strong> which makes the variable immutable.</p>
<p><img decoding="async" class="alignnone size-full wp-image-999" src="https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.43.27.png" alt="" width="489" height="153" srcset="https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.43.27.png 489w, https://creatronix.de/wp-content/uploads/2017/08/Bildschirmfoto-2017-08-18-um-21.43.27-300x94.png 300w" sizes="(max-width: 489px) 100vw, 489px" /></p>
<p>&nbsp;</p>
<p>The post <a href="https://creatronix.de/es6-var-vs-let-vs-const/">ES6: var vs let vs const</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Lint your JavaScript with grunt and jshint</title>
		<link>https://creatronix.de/lint-your-javascript-with-grunt-and-jshint/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Tue, 08 Aug 2017 08:30:58 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[grunt]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[jshint]]></category>
		<category><![CDATA[yarn]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=948</guid>

					<description><![CDATA[<p>After I&#8217;ve introduced You to Yarn I will show You more client side tools in this post. Grunt is a task runner which comes in handy for a lot of setup and configuring work e.g. concatenating and minimizing JavaScript or CSS files To get started You can add grunt via yarn to your project yarn&#8230;</p>
<p>The post <a href="https://creatronix.de/lint-your-javascript-with-grunt-and-jshint/">Lint your JavaScript with grunt and jshint</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>After I&#8217;ve introduced You to <a href="https://creatronix.de/yarn-package-manager/">Yarn</a> I will show You more client side tools in this post.</p>
<p><a href="https://gruntjs.com/">Grunt </a>is a task runner which comes in handy for a lot of setup and configuring work e.g. concatenating and minimizing JavaScript or CSS files</p>
<p>To get started You can add grunt via yarn to your project</p>
<pre>yarn add grunt</pre>
<h2>Configuration</h2>
<p>Grunt looks for a Gruntfile.js file in your root directory. Yes it is Gruntfile.js with a capital &#8216;G&#8217;.</p>
<h2>Linting with JShint</h2>
<pre>yarn add grunt-contrib-jshint</pre>
<pre>module.exports = function(grunt) {
  grunt.initConfig({
    jshint: {
      all: ['Gruntfile.js', '/js/*.js'],
      options: {
        globals: {
          jQuery: true
        }
      }
    }
  });
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.registerTask('lint', ['jshint']);
};</pre>
<p>This configuration will print all findings directly onto the console which is nice for testing the script but when you burn down your lint issues a file comes in handy.</p>
<h2>Configuring JSHint&#8217;s Output Format</h2>
<p>To visualize the findings in Jenkins you can configure the checkstyle format. It produces an XML file which you can use inside Jenkins&#8217; checkstyle plugin.</p>
<p>When You want to have a more human readable format you can generate an html report. Therefore You have to install the jshint-html-reporter:</p>
<pre>yarn add jshint-html-reporter</pre>
<p>and configure the JSHint task accordingly.</p>
<pre>options: {
   reporter: require('jshint-html-reporter'),
   reporterOutput: 'jshint.html'
 },</pre>
<p>You can have both configurations in one file</p>
<pre>module.exports = function(grunt) {

  grunt.initConfig({
    jshint: {
      options: {
        globals: {
          jQuery: true
        }
      },
      src_files: ['Gruntfile.js', 'app/static/js/*.js'],
      local: {
        options: {
          reporter: require('jshint-html-reporter'),
          reporterOutput: 'jshint.html'
        },
        src: [ "&lt;%= jshint.src_files %&gt;" ]
      },
      jenkins: {
        options: {
            reporter: 'checkstyle',
            reporterOutput: 'jshint.xml'
        },
        src: [ "&lt;%= jshint.src_files %&gt;" ]
    }
    }
  });
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.registerTask('lint', ['jshint:jenkins']);
  grunt.registerTask('lint-local', ['jshint:local']);
};</pre>
<p>&nbsp;</p>
<p>The post <a href="https://creatronix.de/lint-your-javascript-with-grunt-and-jshint/">Lint your JavaScript with grunt and jshint</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Yarn &#8211; An alternative package manager for node.js</title>
		<link>https://creatronix.de/yarn-package-manager/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Fri, 28 Jul 2017 10:34:58 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[npm]]></category>
		<category><![CDATA[yarn]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=934</guid>

					<description><![CDATA[<p>Fiddling around with the wire webapp which is available on GitHub I came across yarn. Yarn is a package manager like npm which accesses the same repositories. The design goals are reproducibility of builds, speed and security. Installation npm install -g yarn or on macOS brew install yarn yarn --version A new yarn project can&#8230;</p>
<p>The post <a href="https://creatronix.de/yarn-package-manager/">Yarn &#8211; An alternative package manager for node.js</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="alignnone size-large wp-image-4586" src="https://creatronix.de/wp-content/uploads/2022/01/img_1921-1024x768.jpg" alt="" width="525" height="394" srcset="https://creatronix.de/wp-content/uploads/2022/01/img_1921-1024x768.jpg 1024w, https://creatronix.de/wp-content/uploads/2022/01/img_1921-300x225.jpg 300w, https://creatronix.de/wp-content/uploads/2022/01/img_1921-768x576.jpg 768w, https://creatronix.de/wp-content/uploads/2022/01/img_1921-1536x1152.jpg 1536w, https://creatronix.de/wp-content/uploads/2022/01/img_1921-2048x1536.jpg 2048w" sizes="(max-width: 525px) 100vw, 525px" /></p>
<p>Fiddling around with the wire webapp which is available on GitHub I came across yarn.</p>
<p><a href="https://yarnpkg.com/lang/en/">Yarn </a>is a package manager like npm which accesses the same repositories.</p>
<p>The design goals are reproducibility of builds, speed and security.</p>
<h2>Installation</h2>
<pre>npm install -g yarn</pre>
<p>or on macOS<span id="more-934"></span></p>
<pre><code>brew install yarn</code></pre>
<pre>yarn --version</pre>
<p>A new yarn project can be started with &#8220;yarn init&#8221;.  After a couple of questions yarn creates a package.json file for you.</p>
<pre>$ yarn init
yarn init v0.27.5
question name (yarn_test): yarn_test
question version (1.0.0): 1.0.0
question description: see how it works
question entry point (index.js): index.js
question repository url:
question author: jboegeholz
question license (MIT): MIT
success Saved package.json
Done in 35.38s.</pre>
<p>Adding dependencies is easy as well:</p>
<pre> $ yarn add grunt
 yarn add v0.27.5
 info No lockfile found.
 [1/4] Resolving packages...
 [2/4] Fetching packages...
 [3/4] Linking dependencies...
 [4/4] Building fresh packages...
 success Saved lockfile.
 success Saved 89 new dependencies.</pre>
<p><img decoding="async" class="alignnone size-full wp-image-945" src="https://creatronix.de/wp-content/uploads/2017/07/Bildschirmfoto-2017-07-31-um-20.26.06.png" alt="" width="810" height="624" srcset="https://creatronix.de/wp-content/uploads/2017/07/Bildschirmfoto-2017-07-31-um-20.26.06.png 810w, https://creatronix.de/wp-content/uploads/2017/07/Bildschirmfoto-2017-07-31-um-20.26.06-300x231.png 300w, https://creatronix.de/wp-content/uploads/2017/07/Bildschirmfoto-2017-07-31-um-20.26.06-768x592.png 768w" sizes="(max-width: 810px) 100vw, 810px" /></p>
<p>After adding the first dependency yarn downloads all sub-dependencies as well. On interesting fact is the creation of a lock file for dependency versions. That means If you check in the yarn.lock that you can reproduce your builds deterministically.</p>
<p><img decoding="async" class="alignnone size-full wp-image-942" src="https://creatronix.de/wp-content/uploads/2017/07/Bildschirmfoto-2017-07-31-um-20.20.43.png" alt="" width="758" height="348" srcset="https://creatronix.de/wp-content/uploads/2017/07/Bildschirmfoto-2017-07-31-um-20.20.43.png 758w, https://creatronix.de/wp-content/uploads/2017/07/Bildschirmfoto-2017-07-31-um-20.20.43-300x138.png 300w" sizes="(max-width: 758px) 100vw, 758px" /></p>
<p>When you already a project setup you can easily install all dependencies with:</p>
<pre>$ yarn install</pre>
<p>The post <a href="https://creatronix.de/yarn-package-manager/">Yarn &#8211; An alternative package manager for node.js</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Node.js with PyCharm</title>
		<link>https://creatronix.de/node-js-with-pycharm/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Sun, 28 May 2017 14:57:21 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=721</guid>

					<description><![CDATA[<p>PyCharm amazes me every time. Although it is first and foremost a python IDE you can do full stack web development with it, i. e. you have code completion for HTML, CSS, JavaScript and even TypeScript, CoffeeScript. I wanted to code some node.js stuff and Jetbrains already got a plugin for PyCharm. Before installation: https://www.jetbrains.com/help/pycharm/2017.1/node-js-and-npm.html&#8230;</p>
<p>The post <a href="https://creatronix.de/node-js-with-pycharm/">Node.js with PyCharm</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>PyCharm amazes me every time. Although it is first and foremost a python IDE you can do full stack web development with it, i. e. you have code completion for HTML, CSS, JavaScript and even TypeScript, CoffeeScript.</p>
<p>I wanted to code some node.js stuff and Jetbrains already got a plugin for PyCharm. Before installation:</p>
<p><img decoding="async" class="alignnone wp-image-730 size-large" src="https://creatronix.de/wp-content/uploads/2017/05/Bildschirmfoto-2017-05-28-um-21.06.23-1024x406.png" alt="" width="700" height="278" srcset="https://creatronix.de/wp-content/uploads/2017/05/Bildschirmfoto-2017-05-28-um-21.06.23-1024x406.png 1024w, https://creatronix.de/wp-content/uploads/2017/05/Bildschirmfoto-2017-05-28-um-21.06.23-300x119.png 300w, https://creatronix.de/wp-content/uploads/2017/05/Bildschirmfoto-2017-05-28-um-21.06.23-768x305.png 768w, https://creatronix.de/wp-content/uploads/2017/05/Bildschirmfoto-2017-05-28-um-21.06.23.png 1422w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<p>https://www.jetbrains.com/help/pycharm/2017.1/node-js-and-npm.html</p>
<p>The installation is painless and after a restart you have full node.js support!</p>
<p><img decoding="async" class="alignnone size-large wp-image-732" src="https://creatronix.de/wp-content/uploads/2017/05/Bildschirmfoto-2017-05-28-um-21.50.10-1024x394.png" alt="" width="700" height="269" srcset="https://creatronix.de/wp-content/uploads/2017/05/Bildschirmfoto-2017-05-28-um-21.50.10-1024x394.png 1024w, https://creatronix.de/wp-content/uploads/2017/05/Bildschirmfoto-2017-05-28-um-21.50.10-300x115.png 300w, https://creatronix.de/wp-content/uploads/2017/05/Bildschirmfoto-2017-05-28-um-21.50.10-768x296.png 768w, https://creatronix.de/wp-content/uploads/2017/05/Bildschirmfoto-2017-05-28-um-21.50.10.png 1476w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<p>&nbsp;</p>
<p>The post <a href="https://creatronix.de/node-js-with-pycharm/">Node.js with PyCharm</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Are You ready? / jQuery struggle</title>
		<link>https://creatronix.de/are-you-ready-jquery-struggle/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Fri, 27 Jan 2017 10:00:55 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[change]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[jquery]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=481</guid>

					<description><![CDATA[<p>$(function() { console.log( "ready!" ); }); is the short form for: $( document ).ready(function() { console.log( "ready!" ); }); Very unintuitive, this does not work: $("input#myInput").bind("change", function(){ }); Instead of &#8220;change&#8221; You have to use &#8220;input&#8221; $("input#myInput").bind("input", function(){ });</p>
<p>The post <a href="https://creatronix.de/are-you-ready-jquery-struggle/">Are You ready? / jQuery struggle</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<pre>$(function() {
    console.log( "ready!" );
});
</pre>
<p>is the short form for:</p>
<pre>$( document ).ready(function() {
    console.log( "ready!" );
});
</pre>
<p>Very <b class="b4"></b>unintuitive, this does not work:</p>
<pre>$("input#myInput").bind("<strong>change</strong>", function(){
});
</pre>
<p>Instead of &#8220;change&#8221; You have to use &#8220;input&#8221;</p>
<pre>$("input#myInput").bind("<strong>input</strong>", function(){
});
</pre>
<p>The post <a href="https://creatronix.de/are-you-ready-jquery-struggle/">Are You ready? / jQuery struggle</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Inefficient jQuery Selectors</title>
		<link>https://creatronix.de/inefficient-jquery-selectors/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Mon, 23 Jan 2017 08:03:57 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[selector]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=426</guid>

					<description><![CDATA[<p>My PyCharm IDE warns me if I use inefficient jQuery selectors: As I am a bit nosy I wanted to know &#8220;how&#8221; inefficient these selectors are. So I compared the inefficient $("#items tbody"); with the optimized $("#items").find("tbody"); Here is the test code: window.onload = function () { test("unoptimized", function () { for(var i = 0;&#8230;</p>
<p>The post <a href="https://creatronix.de/inefficient-jquery-selectors/">Inefficient jQuery Selectors</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>My PyCharm IDE warns me if I use inefficient jQuery selectors:<img decoding="async" class="size-medium wp-image-440 aligncenter" src="https://creatronix.de/wp-content/uploads/2017/01/inefficient_jquery-300x74.png" alt="" width="300" height="74" srcset="https://creatronix.de/wp-content/uploads/2017/01/inefficient_jquery-300x74.png 300w, https://creatronix.de/wp-content/uploads/2017/01/inefficient_jquery.png 376w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>As I am a bit nosy I wanted to know &#8220;how&#8221; inefficient these selectors are. So I compared the inefficient</p>
<pre>$("#items tbody");</pre>
<p>with the optimized</p>
<pre>$("#items").find("tbody");</pre>
<p>Here is the test code:</p>
<pre>window.onload = function () {
    test("unoptimized", function () {
        for(var i = 0; i &lt; 100000; i++){
            $("#items tbody");
        }
        assert(true, "Test finished");
    });
    test("optimized", function () {
        for(var i = 0; i &lt; 100000; i++){
            $("#items").find("tbody");
        }
        assert(true, "Test finished");
    });
};</pre>
<p>I used the little test framework from the book <a href="https://amzn.to/3rcfuni">Adventures of the JavaScript Ninja</a></p>
<p><img decoding="async" class="wp-image-444 aligncenter" src="https://creatronix.de/wp-content/uploads/2017/01/jQuery_performance-300x137.png" alt="" width="374" height="171" srcset="https://creatronix.de/wp-content/uploads/2017/01/jQuery_performance-300x137.png 300w, https://creatronix.de/wp-content/uploads/2017/01/jQuery_performance-768x352.png 768w, https://creatronix.de/wp-content/uploads/2017/01/jQuery_performance.png 777w" sizes="(max-width: 374px) 100vw, 374px" /></p>
<p>The results vary from run to run but the optimized version just takes around 55% of the time which makes it almost <strong>twice as fast</strong>.</p>
<p>Though the single execution is in the nanosecond range, if you heavily rely on using jQuery, it might be worthwhile to optimize your selector statements.</p>
<p><a href="https://github.com/jboegeholz/javascript_katas/blob/master/jquery_test.html">Code on GitHub</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://creatronix.de/inefficient-jquery-selectors/">Inefficient jQuery Selectors</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
