<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Joe Honton</title>
    <description>The latest articles on DEV Community by Joe Honton (@joehonton).</description>
    <link>https://dev.to/joehonton</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F207669%2F27570d89-7821-4ab8-9dae-eacc45555bf3.png</url>
      <title>DEV Community: Joe Honton</title>
      <link>https://dev.to/joehonton</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joehonton"/>
    <language>en</language>
    <item>
      <title>How A Simple 500-Word Memo Changed the Way We Talk About the Internet</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Mon, 18 Oct 2021 15:35:26 +0000</pubDate>
      <link>https://dev.to/joehonton/how-a-simple-500-word-memo-changed-the-way-we-talk-about-the-internet-52fc</link>
      <guid>https://dev.to/joehonton/how-a-simple-500-word-memo-changed-the-way-we-talk-about-the-internet-52fc</guid>
      <description>&lt;p&gt;In March of 1997, Scott Bradner penned a short memo titled “Key Words For Use in RFCs to Indicate Requirement Levels”. It is more commonly referred to as simply RFC 2119. The entire document fits comfortably on two pages of paper.&lt;/p&gt;

&lt;p&gt;That memo would go on to become the single most referenced document of the Internet Engineering Task Force (IETF).&lt;/p&gt;

&lt;p&gt;Some things may be allowed, some things may not. Some things should be accommodated, other things should not. Some things are required and simply must be present in a certain form, other things must never be present.&lt;/p&gt;

&lt;p&gt;Scott Bradner and his 500-word memo (RFC 2119) gave us a way to succinctly specify all of the above, without ambiguity, by defining these five imperatives: MUST, MUST NOT, SHOULD, SHOULD NOT, MAY.&lt;/p&gt;

&lt;p&gt;Nearly every RFC written in the past 25 years has referenced RFC 2119 and used these imperatives to be explicit about what is mandatory, what is advisable, and what is allowed but not required.&lt;/p&gt;

&lt;p&gt;Interestingly, RFC 2119 itself has only ever been updated once, to clarify that when these imperatives are not capitalized, they have their normal English meanings.&lt;/p&gt;

&lt;p&gt;A longer version of this was posted to &lt;a href="https://levelup.gitconnected.com/2021-043-how-a-simple-500-word-memo-changed-the-way-we-talk-about-the-internet-c625cbadff86"&gt;The unlikely trio MUST, SHOULD, and MAY in internet standards&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>worldstandardsday</category>
    </item>
    <item>
      <title>Variations on the HTML Two-Step</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Thu, 08 Jul 2021 19:08:48 +0000</pubDate>
      <link>https://dev.to/joehonton/variations-on-the-html-two-step-cbn</link>
      <guid>https://dev.to/joehonton/variations-on-the-html-two-step-cbn</guid>
      <description>&lt;p&gt;It’s not that HTML is impossible to read or write — it’s just awkward.&lt;/p&gt;

&lt;p&gt;For starters there’s the pinky finger problem. You know — the keyboard sequence for creating a tag: the left pinky finger holds down the Shift key while the right middle finger searches for the &amp;lt; key . . . then you release the Shift key while typing the tag's mnemonic characters . . . then once again with the left pinky Shift key thingy, while the right ring finger (or is it the one next to it?) fumbles around for the &amp;gt; key.&lt;/p&gt;

&lt;p&gt;Then — after composing the paragraph or phrase or word — the whole process is repeated with the closing tag, with all the same keystrokes plus the ergonomic &lt;em&gt;coup de grâce&lt;/em&gt;: the right pinky hitting the / key while remembering that the left pinky should momentarily let up on pressing the Shift key!&lt;/p&gt;

&lt;p&gt;Try doing this for a sustained period and you’ll soon be filing a worker’s compensation claim for ergonomic injury. It’s like the party game Twister, where your body parts get tied in knots just by following the rules.&lt;/p&gt;

&lt;p&gt;So writing HTML is unpleasant, but what about reading it?&lt;br&gt;
In actual practice, HTML tags seldom appear stand-alone. Attributes are frequently applied to tags in order to associate them with styling rules (CSS). And on dynamic documents, attributes are applied to tags for dynamic manipulation (JavaScript). Both of these clutter the document significantly. &lt;/p&gt;

&lt;p&gt;But the real problem is that tags and attributes aren’t just lightly sprinkled here and there; they’re dumped all over the document in a downpour — like one of those climate change rainfalls that floods the city so you can’t see the streets anymore.&lt;/p&gt;

&lt;p&gt;Reading an HTML document — even one that has color syntax highlighting — makes you wish there was a legal signal-to-noise limit, with offenders getting fined. It’s not uncommon to discover documents where the noise is so many times greater than the signal that it’s impossible to find the author’s words.&lt;/p&gt;

&lt;p&gt;If Clara Peller was still around, she’d be demanding to know “Where’s the content?”&lt;/p&gt;

&lt;p&gt;HTML wasn’t supposed to be like this.&lt;/p&gt;




&lt;p&gt;Excerpted from &lt;a href="https://medium.com/javascript-fanboi/2021-046-variations-on-the-html-two-step-11f975eb8630"&gt;Variations on the HTML Two-Step&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>html</category>
    </item>
    <item>
      <title>Excellence in Software</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Thu, 22 Apr 2021 02:36:29 +0000</pubDate>
      <link>https://dev.to/joehonton/excellence-in-software-1c91</link>
      <guid>https://dev.to/joehonton/excellence-in-software-1c91</guid>
      <description>&lt;p&gt;The “Excellence in Software” score that all software should strive for is “AAAA”. This is tough. Only the very best will achieve it.&lt;/p&gt;

&lt;p&gt;The acceptance criteria to use depends upon the type of software under development. For many apps and websites the criteria would be close to the following, with items grouped into four sections: accuracy, usability, safety and compliance. Consider these to be a good starting point.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accuracy.&lt;/strong&gt; These are the classic measures of bug-free software.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does the software consistently produce correct results?&lt;/li&gt;
&lt;li&gt;Does the software gracefully handle situations with missing, invalid or extreme input data?&lt;/li&gt;
&lt;li&gt;Does the software faithfully save and restore user data?&lt;/li&gt;
&lt;li&gt;Do sorting routines correctly work with foreign language data?&lt;/li&gt;
&lt;li&gt;Do search routines find and filter results in a way the user expects?&lt;/li&gt;
&lt;li&gt;Do summary records always reflect the true sum of the details?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Usability.&lt;/strong&gt; These are measures of how well the software accommodates users with different levels of sophistication; users having older hardware; and users with less-than 20/20 health.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does the software work on every device and browser used by the top 98% of users?&lt;/li&gt;
&lt;li&gt;Does the user interface have readily available hints and prompts to help new users understand and operate each aspect of the software?&lt;/li&gt;
&lt;li&gt;Are form validation messages given to the user in a place and manner that is obvious?&lt;/li&gt;
&lt;li&gt;Do background colors and text colors have sufficient contrast to be readable?&lt;/li&gt;
&lt;li&gt;Does informational feedback still work for people with protanopia (red-green color blindness)?&lt;/li&gt;
&lt;li&gt;Do web components and generic HTML tags have appropriate WAI-ARIA roles assigned?&lt;/li&gt;
&lt;li&gt;Does the software accommodate screen readers by numbering HTML tabindex attributes in a most-significant to least-significant order?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Safety.&lt;/strong&gt; These are measures of how well the user’s data is protected from accidental loss, bad actors, and catastrophic failures.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does the data backup schedule provide a stable snapshot of everything at hourly, daily, and weekly intervals?&lt;/li&gt;
&lt;li&gt;Can the data restoration process be completed within two hours?&lt;/li&gt;
&lt;li&gt;Is the catastrophic data storage facility in a separate location from the online data?&lt;/li&gt;
&lt;li&gt;Are user credentials properly encrypted during storage and during network transmission?&lt;/li&gt;
&lt;li&gt;Is multi-factor authentication triggered when access is requested from a new location?&lt;/li&gt;
&lt;li&gt;Are web servers configured to use up-to-date TLS protocols?&lt;/li&gt;
&lt;li&gt;Are the website’s Content Security Policy (CSP), Feature Policy, and Referrer Policy properly set up to detect and report breaches?&lt;/li&gt;
&lt;li&gt;Are sequential records protected from brute force and replay attacks?&lt;/li&gt;
&lt;li&gt;Are user interface redress attacks prevented with proper use of the frame-ancestors CSP header directive?&lt;/li&gt;
&lt;li&gt;Is user input sanitized to catch cross-site scripting injections when saving data to the database?&lt;/li&gt;
&lt;li&gt;Are financial transactions protected with the use of HMAC-based cross-site request forgery tokens?&lt;/li&gt;
&lt;li&gt;Have all files been scanned for viruses before deployment?&lt;/li&gt;
&lt;li&gt;Are DevOps’ server credentials stored separately and outside project repositories?&lt;/li&gt;
&lt;li&gt;Does the project’s testing protocol include explicit checks for common data breaches?&lt;/li&gt;
&lt;li&gt;Are web server access logs regularly monitored for abnormal conditions?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Compliance.&lt;/strong&gt; These are measures of the software’s adherence to industry standards and civil law.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Do the website’s documents use HTML and CSS in a way that passes W3C validators?&lt;/li&gt;
&lt;li&gt;Do browsers evaluate the website’s JavaScript without generating console warnings or errors?&lt;/li&gt;
&lt;li&gt;Does the website have a data privacy policy that complies with the General Data Protection Regulation (GDPR) and the California Consumer Privacy Act (CCPA)?&lt;/li&gt;
&lt;li&gt;Does the software’s eCommerce process comply with Payment Card Industry Data Security Standards (PCI DSS)?&lt;/li&gt;
&lt;li&gt;Does the software comply with the Access to Information and Communication Technology (ICT) Section 508 standards for government sites?&lt;/li&gt;
&lt;li&gt;Does the software adhere to the terms and conditions of each third-party software license it uses?&lt;/li&gt;
&lt;li&gt;Are third-party software libraries that are distributed under GNU or MIT licenses properly acknowledged on a public-facing document?&lt;/li&gt;
&lt;li&gt;Does DevOps have a written schedule of expiration and renewal dates for all limited term licenses?&lt;/li&gt;
&lt;li&gt;Has the company established a vulnerability disclosure policy with a way for outside security researchers and bounty hunters to privately provide notification of issues?&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Excerpted from &lt;a href="https://levelup.gitconnected.com/2021-045-excellence-in-software-665e491bbafe"&gt;Excellence in Software&lt;/a&gt; originally published in Level Up Coding.&lt;/p&gt;

</description>
      <category>codequality</category>
    </item>
    <item>
      <title>Taking Responsibility for Ethical Design</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Mon, 05 Apr 2021 16:52:10 +0000</pubDate>
      <link>https://dev.to/joehonton/taking-responsibility-for-ethical-design-3djl</link>
      <guid>https://dev.to/joehonton/taking-responsibility-for-ethical-design-3djl</guid>
      <description>&lt;p&gt;We have an ethical dilemma: how can we protect an individual’s personal data from misuse, while still providing a useful experience?&lt;/p&gt;

&lt;p&gt;There are aspects to this that need our thoughtful consideration: data as a commodity, data amalgamation without express consent, data archival for indefinite periods of time, the expungement of data for the protection of our youth, data custodianship version ownership, and others like these.&lt;/p&gt;

&lt;p&gt;In short, for each new tech project we should be asking: why are we collecting this data? how long do we really need to keep it? and what harm could result from its misuse by us and others?&lt;/p&gt;

&lt;p&gt;In days gone by, public domain records were limited to birth, wedding, and death certificates. For anything else, the picture was filled out by family albums and newspaper clippings. Data archiving was limited to what the archivist could squeeze into his cinder-block storage facility. Data retention was fallible: fires, floods, and mold took turns at reducing history to a sketch.&lt;/p&gt;

&lt;p&gt;In contrast, today it seems that everything we’ve ever done, said, posted, or photographed, is being captured and archived, unable to fade from memory.&lt;/p&gt;

&lt;p&gt;But some things should be forgotten, otherwise our children won’t be able to grow up and experiment and make mistakes. Teenagers need to be protected from themselves. We need to have regulations in place to allow them to expunge the data of their misdeeds, their bad choice of words, their poor judgment with cameras. How else can we protect them from being forever dragged down after they’ve matured?&lt;/p&gt;

&lt;p&gt;And we need to have better rules about the ownership of data we generate as a by-product of our tech activities. Who should have ultimate control over the ownership and retention rights of such data, the individual, or the business that stores it? Who really owns it? If internet companies are custodians of that data, what responsibilities do they have to the people whose lives are being recorded?&lt;/p&gt;

&lt;p&gt;We need to develop a social contract, where tech companies and the users they serve, agree that personal data is not a commodity. At a minimum it should begin with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A non-amalgamation clause in our end-user licensing agreements that restricts or prevents us from joining data that we collect with data that we obtain from third parties without express consent from the user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A data retention clause that prohibits the archival of transaction data for unlimited periods of time without the express consent of the user, and that mandates that we erase those transactions when that period expires.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A data collection clause that restricts us from capturing or storing ephemeral data, such as GPS way-points.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A data purging clause that specifies how long usage data — such as movies seen, books read, or music listened to — can be kept before mandatory deletion must occur.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When we start putting these kinds of guidelines in place, we’ll begin to regain the trust that’s been lost.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Excerpted from &lt;a href="https://medium.com/javascript-fanboi/2020-006-ethical-design-in-the-orwellian-commons-6ef924f03753"&gt;Ethical Design in the Orwellian Commons&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>commentary</category>
      <category>privacy</category>
      <category>bigdata</category>
    </item>
    <item>
      <title>Cross Domain JSON Requests</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Mon, 29 Mar 2021 17:10:34 +0000</pubDate>
      <link>https://dev.to/joehonton/cross-domain-json-requests-1g5</link>
      <guid>https://dev.to/joehonton/cross-domain-json-requests-1g5</guid>
      <description>&lt;p&gt;The use of dynamic requests to backend servers is prevalent in modern web applications. Despite its commonplace nature, there are some &lt;em&gt;gotchas&lt;/em&gt; that trip up even experienced developers.&lt;/p&gt;

&lt;h3&gt;
  
  
  TL;DR
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;In order to successfully preflight a JSON-encoded request to a different domain, the &lt;em&gt;browser's&lt;/em&gt; fetch request must include the HTTP header &lt;code&gt;access-control-request-headers: content-type&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In order to signal that a JSON-encoded request from a different domain is permitted, the &lt;em&gt;remote server&lt;/em&gt; must be correctly configured to respond with the HTTP header &lt;code&gt;access-control-allow-headers: content-type&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Basic CORS rules
&lt;/h3&gt;

&lt;p&gt;Before getting started, let's review when Cross Origin Resource Sharing (CORS) is required.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CORS is only used when a web page needs to access something that is hosted on a       different domain.&lt;/li&gt;
&lt;li&gt;CORS is never used for HTTP requests made with the methods: &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;HEAD&lt;/code&gt; or &lt;code&gt;OPTIONS&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;CORS is a browser-to-server protocol. It &lt;em&gt;uses&lt;/em&gt; HTTP for communication, but HTTP &lt;em&gt;per se&lt;/em&gt; knows nothing about CORS. Because of this, requests sent via &lt;code&gt;cURL&lt;/code&gt;, or tools
  like &lt;code&gt;Postman&lt;/code&gt;, do not involve CORS, and will succeed, while the same request made by the browser will fail.&lt;/li&gt;
&lt;li&gt;CORS does not enhance website security, rather it weakens security. Implementing it carefully is important.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Simple CORS requests
&lt;/h3&gt;

&lt;p&gt;There are two types of CORS requests: simple and preflight.&lt;/p&gt;

&lt;p&gt;Consider a scenario where a web page hosted on &lt;code&gt;www.example.com&lt;/code&gt; submits a &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; to a backend server at &lt;code&gt;api.example.com&lt;/code&gt;. This is an example of a simple CORS request. It follows this path:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The browser determines that the remote resource is not on the same domain as the web page, so it adds an extra header to the &lt;code&gt;POST&lt;/code&gt; request: &lt;code&gt;origin: www.example.com&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The remote server recognizes that this is a request coming from a different host, and checks its rule book to determine how to respond.&lt;/li&gt;
&lt;li&gt;If the specified origin is not in the remote server's configuration, the server responds with status code &lt;code&gt;403&lt;/code&gt; and an empty payload.&lt;/li&gt;
&lt;li&gt;On the other hand, if the remote server is configured to honor requests from the specified origin, it handles the request, returning an appropriate status code such as &lt;code&gt;200&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this example, the type of payload is significant. POST requests having content type &lt;code&gt;application/x-www-form-urlencoded&lt;/code&gt; are made using the simple CORS protocol. This is the HTML &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; submission standard. Here's what the software developer codes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.example.com/order_handler&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cors&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;wwwFormData&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One further note before moving on, the use of the CORS protocol is only triggered by the browser when &lt;em&gt;dynamic&lt;/em&gt; requests are made by JavaScript. In the above example, if the &lt;code&gt;wwwFormData&lt;/code&gt; had been submitted directly by a SUBMIT button, CORS would not be invoked. The HTML for this type of submission is simply:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;'https://api.example.com/order_handler'&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;'POST'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Preflight CORS
&lt;/h3&gt;

&lt;p&gt;The second type of CORS request involves a &lt;span&gt;preflight&lt;/span&gt; request made using the HTTP &lt;code&gt;OPTIONS&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;Consider the same scenario as above, but this time the developer chooses to format the data as JSON. The communication exchange follows this path:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The payload is specified by the developer to be &lt;code&gt;content-type: application/json&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The browser does not recognize this content type as one of the CORS "safelisted types", so it sends an &lt;code&gt;OPTIONS&lt;/code&gt; request to the remote server with two headers &lt;code&gt;origin: www.example.com&lt;/code&gt;
and &lt;code&gt;access-control-request-headers: content-type&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;As before, the remote server checks its configuration rule book to determine whether or not to honor requests from that origin, and further checks to see if it is ready to handle non-standard content types.&lt;/li&gt;
&lt;li&gt;If both of those conditions are satisfied, the server responds to the OPTIONS request with two headers: &lt;code&gt;access-control-allow-origin: www.example.com&lt;/code&gt; and &lt;code&gt;access-control-allow-headers: content-type&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The browser sees that the remote server intends to honor the request, so it issues a POST request with the JSON payload and the &lt;code&gt;origin: www.example.com&lt;/code&gt; and &lt;code&gt;access-control-request-headers: content-type&lt;/code&gt; headers.&lt;/li&gt;
&lt;li&gt;The remote server honors the POST and responds with an appropriate status code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The software developer codes it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.example.com/order_handler&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cors&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;content-type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;jsonData&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Configuring the remote server
&lt;/h3&gt;

&lt;p&gt;Every web server has a way to enable CORS, and a way to allow &lt;code&gt;content-type&lt;/code&gt; headers. Here are links to the docs for a few of them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For Apache Web Server, add this to the remote server's configuration: &lt;code&gt;Header always set Access-Control-Allow-Headers "content-type"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;For Nginx Web Server, add this to the remote server's configuration:  &lt;code&gt;add_header Access-Control-Allow-Headers "content-type"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://blogs.iis.net/iisteam/getting-started-with-the-iis-cors-module"&gt;IIS Server&lt;/a&gt; CORS configuration&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html"&gt;Amazon EC2&lt;/a&gt; CORS configuration&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://rwserve.readwritetools.com/cross-origin.blue"&gt;Read Write Serve HTTP/2 Server&lt;/a&gt; CORS configuration&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Originally published at &lt;a href="https://medium.com/javascript-fanboi/2021-043-cross-domain-json-requests-3c47b382c869"&gt;Cross Domain JSON Requests&lt;/a&gt;. Read more &lt;a href="https://medium.com/javascript-fanboi"&gt;JavaScript Fanboi&lt;/a&gt; articles here.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Infinite Scroll As A Design Pattern</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Mon, 22 Mar 2021 18:28:46 +0000</pubDate>
      <link>https://dev.to/joehonton/infinite-scroll-as-a-design-pattern-379</link>
      <guid>https://dev.to/joehonton/infinite-scroll-as-a-design-pattern-379</guid>
      <description>&lt;p&gt;Software developers wanting to implement infinite scroll can easily get started with the browser's &lt;code&gt;IntersectionObserver&lt;/code&gt; callback function.&lt;/p&gt;

&lt;p&gt;As a working example, we could create a component for use on a blogging site which automatically fetches another article when the reader has reached the end of the original article.&lt;/p&gt;

&lt;p&gt;Here's what the code looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;observer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;IntersectionObserver&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;isIntersecting&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;fetchNextArticle&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;threshold&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bottomOfPage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#bottom-of-page&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bottomOfPage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There isn't much to it. The &lt;code&gt;bottom-of-page&lt;/code&gt; element could be any HTML element, but in its simplest form it is just a clear &lt;code&gt;div&lt;/code&gt;, that has non-zero dimensions, situated somewhere after the original article's content.&lt;/p&gt;

&lt;p&gt;The observer is called when the reader scrolls to a point where the target &lt;code&gt;div&lt;/code&gt; becomes visible. A &lt;code&gt;threshold&lt;/code&gt; value of &lt;code&gt;0&lt;/code&gt; will trigger the callback when any part of the &lt;code&gt;div&lt;/code&gt; is in the viewport. A &lt;code&gt;threshold&lt;/code&gt; value of &lt;code&gt;1&lt;/code&gt; will only trigger it when &lt;em&gt;all&lt;/em&gt; of the &lt;code&gt;div&lt;/code&gt; is in the viewport.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;fetchNextArticle&lt;/code&gt; function is where the just-in-time loading happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;articleUrls&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/feb-28-2021.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/feb-21-2021.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/feb-14-2021.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/feb-07-2021.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nextIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;fetchNextArticle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="c1"&gt;// fetch the article using HTTP&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;articleUrls&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;nextIndex&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;304&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;templateText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// get the &amp;lt;body&amp;gt; of the article's HTML&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;template&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;template&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;templateText&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;template&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;body&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// create a new &amp;lt;article&amp;gt; and insert it&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nextArticle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;article&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;nextArticle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="nx"&gt;bottomOfPage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parentNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;insertBefore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nextArticle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;bottomOfPage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, there are four articles that are queued for just-in-time loading. Of course in practice, that queue should be dynamically built to match the reader's interests.&lt;/p&gt;

&lt;p&gt;This bare-bones example is a good starting point, but savvy developers can easily imagine improvements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Querying the next article's &amp;lt;title&amp;gt; and &amp;lt;meta&amp;gt; tags to extract open graph data, like featured image, dateline, byline, and lede paragraph.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Removing unnecessary headers, footers, menus and advertising links from the article's &amp;lt;body&amp;gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Giving the reader a way to toggle between two views of the article: a collapsed UI card and an expanded full-text view.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of this has been implemented in the &lt;a href="https://domcomponents.com/components/piqueme.blue?utm_term=InfiniteScrollAsADesignPattern"&gt;rwt-piqueme&lt;/a&gt; DOM component, which is ready-to-use via &lt;a href="https://www.npmjs.com/package/rwt-piqueme"&gt;NPM&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;(An expanded version of this article originally appeared on &lt;a href="https://medium.com/javascript-fanboi/2021-040-infinite-scroll-as-a-design-pattern-859ecc45287a"&gt;Medium&lt;/a&gt;.)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Every Place That Uses Daylight Saving Time</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Tue, 16 Mar 2021 02:08:03 +0000</pubDate>
      <link>https://dev.to/joehonton/every-place-that-uses-daylight-saving-time-25eb</link>
      <guid>https://dev.to/joehonton/every-place-that-uses-daylight-saving-time-25eb</guid>
      <description>&lt;p&gt;Software developers work with dates and times on a regular basis. We understand the rules for determining leap years, the methods for calculating time spans, and the proper use of time offsets from Coordinated Universal Time.&lt;/p&gt;

&lt;p&gt;Unfortunately, when it comes to summer-time versus winter-time there’s a big gap in our understanding. Relying on the time broadcast from the nearest cell-phone tower may be good enough for lay people, but programmers need to know a lot more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Standard time zones
&lt;/h2&gt;

&lt;p&gt;We know that standard time is nominally sliced into 24 zones, each of 15 degrees longitude. But the true list of standard times is not that clean, because many places have decided to stretch and pull time zone borders to fit administrative borders. This has given rise to time zones that are unusually wide, such as China, whose eastern limit at 73.5°E, and western limit at 134.5°E, spans four nominal time zones.&lt;/p&gt;

&lt;p&gt;Other countries have adopted time zones that don’t neatly fit the usual one hour increment. For example, India standard time is 30 minutes different from neighboring Pakistan and Bangladesh. And strange as it may seem, Nepal standard time is set at the 45 minute mark, meaning clocks in Kathmandu are two hours and fifteen minutes behind its neighbor to the north.&lt;/p&gt;

&lt;p&gt;Furthermore, in the South Pacific, some islands have decided to align their clocks with the east and others with the west. They’ve contorted those 24 nominal slices into 26 actual zones. This may seem odd to mainlanders, but it does prevent the awkwardness and confusion of dealing with trading partners whose clocks and calendars might otherwise be different.&lt;/p&gt;

&lt;p&gt;And then there’s daylight saving time. This perplexing idea and its non-uniform set of rules has been generating controversy ever since it was first tried in 1916.&lt;/p&gt;

&lt;p&gt;Nobody likes the idea of getting out of bed at 4 o’clock in the morning, even if that’s when the sun rises. So why not get up at 5 o’clock, and use that extra hour of summer daylight to do some extra work in the evening.&lt;/p&gt;

&lt;p&gt;At different times over the past century, daylight saving time has been enacted or repealed by countries which have justified their reasoning in a variety of ways: wartime production schedules; the availability and price of oil; computerized electoral machines that couldn’t be reprogrammed; severe drought drying up hydroelectric dams; better use of national tourist attractions; accommodating the daylight fasting rules of Ramadan. And in one case — favoring restaurant diners over beach-goers!&lt;/p&gt;

&lt;p&gt;The rules keep changing. Savvy programmers must take defensive action in whatever implementation they choose. Here’s a round-the-world examination of the daylight saving rules for 2021.&lt;/p&gt;

&lt;p&gt;For the list of zones for the whole world see &lt;a href="https://medium.com/javascript-fanboi/2021-041-every-place-that-uses-daylight-saving-time-6699c8a4e3ae"&gt;Medium.com&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Data files for software developers
&lt;/h2&gt;

&lt;p&gt;Time zone data and daylight time rules are administered by the Internet Assigned Numbers Authority. The Time Zone Database is available for download from IANA.&lt;/p&gt;

&lt;p&gt;This database is maintained by volunteers who submit changes that they learn about through local news. Every country in the world is free to use whatever time zones and whatever daylight rules they wish, and they are under no obligation to inform IANA about any changes. Volunteers are needed to keep the database up-to-date.&lt;/p&gt;

&lt;p&gt;Daylight saving time data files for 2021 can be obtained from the &lt;a href="https://github.com/readwritetools/daylight-saving-time-2021"&gt;daylight-saving-time-2021&lt;/a&gt; GitHub repo.&lt;/p&gt;

&lt;p&gt;Time zone data visualization is available at &lt;a href="https://timezone.earth/?utm_term=EveryPlaceThatUsesDaylightSavingTime"&gt;timezone.earth&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>timezones</category>
      <category>daylightsavingtime</category>
    </item>
    <item>
      <title>JavaScript Modules Versus Components</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Tue, 02 Mar 2021 18:39:51 +0000</pubDate>
      <link>https://dev.to/joehonton/javascript-modules-versus-components-4le3</link>
      <guid>https://dev.to/joehonton/javascript-modules-versus-components-4le3</guid>
      <description>&lt;p&gt;&lt;em&gt;Excerpted from &lt;a href="https://medium.com/javascript-fanboi/2021-037-javascript-modules-versus-components-dcaeeb0b3b8d"&gt;Medium.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript we learn that “A module is just a file. One script is one module. As simple as that.”&lt;/p&gt;

&lt;p&gt;But of course nothing is simple in JavaScript: there are AMD modules, CommonJS modules, UMD modules, and native ES modules.&lt;/p&gt;

&lt;p&gt;And when we finally wrap our heads around the module mess, we’re still left with a variety of definitions for “component”, which is where the confusion begins to get opinionated.&lt;/p&gt;

&lt;p&gt;Way back in 2011, the Web Hypertext Application Technology Working Group (WHATWG) defined the Component Model to complement its work on the all-important Document Object Model (DOM).&lt;/p&gt;

&lt;p&gt;To quote from the WHATWG wiki: “The Component Model introduces comprehensive support for creating DOM elements.” And it goes on to explain that “the Component Model formalizes the concept of loosely coupled, coherent units of behavior in the Web platform.”&lt;/p&gt;

&lt;p&gt;This was at a time in history when you could explain it this way — to the delight of everyone: “Examples include layout managers, combinations of Dojo and jQuery widgets, isolated widgets, such as Like/+1 buttons, and built-in HTML elements themselves.”&lt;/p&gt;

&lt;p&gt;Lately, I’ve been hearing the phrase “vanilla JavaScript” used to indicate that no framework or library is involved in a coding solution. So in a similar fashion, it appears that “vanilla component” could be a good way out of this mess. Personally, I like to call them &lt;a href="https://domcomponents.com/?utm_term=JavaScriptModulesVersusComponents"&gt;DOM Components&lt;/a&gt;, giving credit where credit is due.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webcomponents</category>
    </item>
    <item>
      <title>Take Control of Mouse and Touch Events to Create Your Own Gestures</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Tue, 23 Feb 2021 00:40:07 +0000</pubDate>
      <link>https://dev.to/joehonton/take-control-of-mouse-and-touch-events-to-create-your-own-gestures-3nc9</link>
      <guid>https://dev.to/joehonton/take-control-of-mouse-and-touch-events-to-create-your-own-gestures-3nc9</guid>
      <description>&lt;p&gt;Developers looking for an easy way to listen for gestures will find no support from the browser. Gestures must be built from the underlying pointer events and mouse events APIs. Further complicating matters, those APIs are not symmetrical. &lt;/p&gt;

&lt;p&gt;Handling the raw mouse and touch events is the key to creating a gesture API.&lt;/p&gt;

&lt;p&gt;These are the steps a developer will need to take to recognize gestures:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Capture the starting and ending position of each finger or mouse pointer.&lt;/li&gt;
&lt;li&gt;Compute the distance and direction of each pointer’s movement.&lt;/li&gt;
&lt;li&gt;Calculate the geometric relationship between multiple pointers.&lt;/li&gt;
&lt;li&gt;Determine a pointer’s speed using the system clock.&lt;/li&gt;
&lt;li&gt;Check whether any special touch zones should be applied.&lt;/li&gt;
&lt;li&gt;Suppress any automatic browser-generated actions.&lt;/li&gt;
&lt;li&gt;Discard any unwanted raw events.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The algebra for each of these is in this &lt;a href="https://medium.com/javascript-fanboi/2021-036-take-control-of-mouse-and-touch-events-e63c9a5a85a7"&gt;full length article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Key points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simple gestures like tap, press, and doubletap can be recognized from a single stationary pointer.&lt;/li&gt;
&lt;li&gt;Gestures like horizontalflick and verticalflick can be distinguished from swipeleft/swiperight and scrollup/scrolldown by monitoring the system clock.&lt;/li&gt;
&lt;li&gt;Two finger-gestures can recognize a change in their relative distance as a pinch or spread.&lt;/li&gt;
&lt;li&gt;Two fingers moving in tandem can be recognized as horizontalpan, verticalpan, or a twofingertap.&lt;/li&gt;
&lt;li&gt;Two fingers with a change in the sweep angle can be recognized as a clockwise or counterclockwise gesture.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For demonstration purposes, many of these have been implemented in the gesture API used by the &lt;a href="https://simply.earth/?utm_term=devto"&gt;Simply Earth&lt;/a&gt; website. When viewed on the desktop, the mouse plus Ctrl, Alt, Shift combinations are used to initiate gestures. When viewed on mobile devices, two-fingers are used to initiate all of the same gestures.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>ui</category>
      <category>ux</category>
    </item>
    <item>
      <title>Has Open Source Licensing Reached Its End of Life?</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Mon, 15 Feb 2021 14:43:36 +0000</pubDate>
      <link>https://dev.to/joehonton/has-open-source-licensing-reached-its-end-of-life-3jgk</link>
      <guid>https://dev.to/joehonton/has-open-source-licensing-reached-its-end-of-life-3jgk</guid>
      <description>&lt;p&gt;Recently, I finished working on a software project that I’m especially proud of. It took months of effort to complete, and the final result was something that perfectly fit my needs. It was a labor of love.&lt;/p&gt;

&lt;p&gt;It’s not important to reveal the purpose of the software here, or the technical details of its inner workings. Simply allow me to say that it’s something that I will use right away, and that other programmers may find useful as well.&lt;/p&gt;

&lt;p&gt;When the project was complete, there were a few important decisions that I needed to make. How do I share what I’ve created? How can I get fair compensation for my efforts? And how do I protect what I’ve created from unscrupulous profiteers?&lt;/p&gt;

&lt;p&gt;Getting fair compensation for our individual efforts is part of the equation here. Yes, I’m aware that GPL licensing makes a distinction between “Free as in Speech” and “Free as in Beer”. Yes, I know that &lt;em&gt;I can charge a fee&lt;/em&gt; for my efforts.&lt;/p&gt;

&lt;p&gt;I’m curious to know what other software developers are doing about this. What considerations go into the decision-making process? What works and what doesn’t?&lt;/p&gt;

&lt;p&gt;Lately I’ve begun to wonder if open-source licensing has failed to keep up with technology. The first version of GPL debuted in 1989, and was updated soon after in 1991. The most recent revision of GPL was in 2007. That was 14 years ago!&lt;/p&gt;

&lt;p&gt;I've explored this topic more fully in this &lt;a href="https://medium.com/javascript-fanboi/2021-035-has-open-source-licensing-reached-its-end-of-life-d04243acd042"&gt;JavaScript Fanboi&lt;/a&gt; article.&lt;/p&gt;

&lt;p&gt;I haven’t figured out where to go from here, but it feels like something needs to change.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>licensing</category>
    </item>
    <item>
      <title>High Performance HTML Rendering: How to properly use a game loop with HTML canvas drawings</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Mon, 08 Feb 2021 18:17:52 +0000</pubDate>
      <link>https://dev.to/joehonton/high-performance-html-rendering-how-to-properly-use-a-game-loop-with-html-canvas-drawings-1jjp</link>
      <guid>https://dev.to/joehonton/high-performance-html-rendering-how-to-properly-use-a-game-loop-with-html-canvas-drawings-1jjp</guid>
      <description>&lt;p&gt;Game programming uses a software pattern called a &lt;em&gt;game loop&lt;/em&gt;. It’s an important technique for any software developer to study, having applicability to serious endeavors beyond graphic animations, for example in: time-series charting, interactive data visualization, and scientific modeling.&lt;/p&gt;

&lt;p&gt;This &lt;a href="https://medium.com/javascript-fanboi/2021-034-high-performance-html-rendering-4372fc32f23c"&gt;article&lt;/a&gt; shows how to improve the continuous &lt;code&gt;requestAnimationFrame&lt;/code&gt; callback to handle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;real-time fidelity,&lt;/li&gt;
&lt;li&gt;throttling things to a fixed rate,&lt;/li&gt;
&lt;li&gt;placing canvas drawing functions behind promises,&lt;/li&gt;
&lt;li&gt;completely skipping unnecessary drawing.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webcomponents</category>
      <category>animation</category>
    </item>
    <item>
      <title>Make Professional Components with Pub/Sub and Custom Events</title>
      <dc:creator>Joe Honton</dc:creator>
      <pubDate>Tue, 02 Feb 2021 03:42:44 +0000</pubDate>
      <link>https://dev.to/joehonton/make-professional-components-with-pub-sub-and-custom-events-kg7</link>
      <guid>https://dev.to/joehonton/make-professional-components-with-pub-sub-and-custom-events-kg7</guid>
      <description>&lt;p&gt;Publish/subscribe is a classic software design pattern that allows pieces of an application to be decoupled. It uses messages instead of functions, closures, or callbacks. It promotes an architectural style that has flexibility through independence.&lt;/p&gt;

&lt;p&gt;I recently applied the pub/sub pattern to the state management of a DOM component. Its implementation was at times confusing, but the final result was a satisfying UI/UX. The extra effort was worth it.&lt;/p&gt;

&lt;p&gt;The full story is on Medium at &lt;a href="https://medium.com/javascript-fanboi/2021-033-pub-sub-and-custom-events-a9ff6f93152"&gt;https://medium.com/javascript-fanboi/2021-033-pub-sub-and-custom-events-a9ff6f93152&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bottom line: The pub/sub pattern helps remove dependencies between the source of truth and the user interface.&lt;/p&gt;

&lt;p&gt;Unfortunately pub/sub can become a tangled mess — because the code for publishing and subscribing are almost always in separate modules. The key to success is staying organized. &lt;/p&gt;

</description>
      <category>pubsub</category>
      <category>javascript</category>
      <category>webcomponents</category>
    </item>
  </channel>
</rss>
