<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Software Engineer Diaries]]></title><description><![CDATA[Software Engineer Diaries]]></description><link>https://swediaries.com</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 06:53:43 GMT</lastBuildDate><atom:link href="https://swediaries.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[HTML NEW Speculation Rules API makes your website super faster!]]></title><description><![CDATA[Make Any Website Load Faster with Just 6 Lines of HTML
Website performance is no longer a “nice to have” — it’s a critical part of user experience.Faster websites keep users engaged, reduce bounce rates, and directly impact SEO rankings.
In this arti...]]></description><link>https://swediaries.com/html-new-speculation-rules-api-makes-your-website-super-faster</link><guid isPermaLink="true">https://swediaries.com/html-new-speculation-rules-api-makes-your-website-super-faster</guid><category><![CDATA[HTML5]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[software development]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Ahmed Muhammady]]></dc:creator><pubDate>Sun, 25 Jan 2026 23:24:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769383025857/bd32eced-a6b9-4d65-ac45-9c9852d1c9f0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-make-any-website-load-faster-with-just-6-lines-of-html">Make Any Website Load Faster with Just 6 Lines of HTML</h1>
<p>Website performance is no longer a “nice to have” — it’s a critical part of user experience.<br />Faster websites keep users engaged, reduce bounce rates, and directly impact SEO rankings.</p>
<p>In this article, I want to share a <strong>simple yet powerful technique</strong> that can noticeably improve perceived page load speed using <strong>only 6 lines of HTML</strong> — no frameworks, no heavy refactoring.</p>
<h1 id="heading-the-core-idea">The Core Idea</h1>
<p>Instead of waiting for the user to click a link before loading the next page, modern browsers can be instructed to <strong>prepare pages in advance</strong>.</p>
<p>Google Chrome recently introduced the <strong>Speculation Rules API</strong>, which allows developers to define rules for <strong>prefetching</strong> and <strong>prerendering</strong> pages that users are likely to visit next.</p>
<p>The result?<br />Pages feel almost instant when the user clicks.</p>
<h1 id="heading-the-magic-code">The magic code</h1>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"speculationrules"</span>&gt;</span><span class="javascript">
  {
    <span class="hljs-string">"prerender"</span>: [{ <span class="hljs-string">"where"</span>: { <span class="hljs-string">"href_matches"</span>: <span class="hljs-string">"/*"</span> }, <span class="hljs-string">"eagerness"</span>: <span class="hljs-string">"moderate"</span> }],
    <span class="hljs-string">"prefetch"</span>: [{ <span class="hljs-string">"where"</span>: { <span class="hljs-string">"href_matches"</span>: <span class="hljs-string">"/*"</span> }, <span class="hljs-string">"eagerness"</span>: <span class="hljs-string">"moderate"</span> }]
  }
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<h1 id="heading-how-it-works">How It Works</h1>
<h3 id="heading-prefetch">🔹 Prefetch</h3>
<ul>
<li><p>Downloads only the HTML of the target page in the background</p>
</li>
<li><p>Uses minimal resources</p>
</li>
<li><p>Ideal for lightweight performance improvements</p>
</li>
</ul>
<h3 id="heading-prerender">🔹 Prerender</h3>
<ul>
<li><p>Fully loads the page (HTML, CSS, JavaScript, images)</p>
</li>
<li><p>Keeps it ready to be displayed instantly</p>
</li>
<li><p>Provides the best perceived speed, but uses more resources</p>
</li>
</ul>
<h3 id="heading-eagerness-moderate">🔹 Eagerness: <code>moderate</code></h3>
<ul>
<li><p>Tells the browser to wait for a short user signal (like hovering over a link)</p>
</li>
<li><p>Avoids aggressive preloading</p>
</li>
<li><p>Strikes a balance between speed and resource usage</p>
</li>
</ul>
<h1 id="heading-why-this-matters">Why This Matters</h1>
<p>✔ <strong>Faster navigation</strong><br />Pages appear instantly when users click links.</p>
<p>✔ <strong>Better user experience</strong><br />Smooth transitions make the website feel responsive and modern.</p>
<p>✔ <strong>Improved engagement</strong><br />Users stay longer on fast websites.</p>
<p>✔ <strong>SEO benefits</strong><br />Page speed is a confirmed ranking factor for search engines.</p>
<h1 id="heading-important-notes">Important Notes</h1>
<ul>
<li><p>This feature is currently supported in <strong>Chrome 121+</strong></p>
</li>
<li><p>Other browsers will safely ignore the rule</p>
</li>
<li><p>If resource usage is a concern, you can use <code>prefetch</code> without <code>prerender</code></p>
</li>
<li><p>Best suited for content-heavy websites with frequent internal navigation</p>
</li>
</ul>
<hr />
<h1 id="heading-final-thoughts">Final Thoughts</h1>
<p>Performance optimization doesn’t always require complex architecture or advanced tooling.<br />Sometimes, <strong>a few well-placed lines of HTML</strong> can make a real difference.</p>
<p>If you’re a Frontend or Full-Stack developer, this is definitely worth experimenting with.</p>
<p>Thanks &lt;3</p>
<p>Ahmed Muhammady.</p>
]]></content:encoded></item><item><title><![CDATA[Dynamic Where Clauses in Laravel: Advantages, Disadvantages, and Examples]]></title><description><![CDATA[When working with Laravel, you may have come across the concept of a dynamic where clause. This feature is often overlooked and not talked about in Laravel discussions, but it can be a powerful tool in your development arsenal. In this post, we will ...]]></description><link>https://swediaries.com/dynamic-where-clauses-in-laravel-advantages-disadvantages-and-examples</link><guid isPermaLink="true">https://swediaries.com/dynamic-where-clauses-in-laravel-advantages-disadvantages-and-examples</guid><dc:creator><![CDATA[Ahmed Muhammady]]></dc:creator><pubDate>Sun, 04 Jun 2023 17:20:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/Y5yxdx2a4PI/upload/34fb0b1ce45c2a9f9052dc7e7bf0b8e3.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>When working with Laravel, you may have come across the concept of a dynamic where clause. This feature is often overlooked and not talked about in Laravel discussions, but it can be a powerful tool in your development arsenal. In this post, we will explore the advantages and disadvantages of using the dynamic where clause in Laravel, and we will use the examples of whereEmail and whereName to illustrate its functionality.</strong></p>
<h2 id="heading-advantages-of-the-dynamic-where-clause"><strong>Advantages of the Dynamic Where Clause</strong></h2>
<p>One of the primary advantages of using the dynamic where clause in Laravel is its flexibility. With this feature, you can dynamically construct your SQL queries based on the conditions you specify. This can be especially useful when working with complex queries that require a lot of conditional statements.</p>
<p>Another advantage of the dynamic where clause is that it allows you to easily build queries that are customizable by the end user. For example, if you are building a search feature for your application, you can use the dynamic where clause to allow users to search for specific attributes like name or email address.</p>
<p>The dynamic where clause can also help you write concise code. Instead of writing multiple if statements to check for different conditions, you can use the dynamic where clause to construct your query in a single line of code.</p>
<h2 id="heading-disadvantages-of-the-dynamic-where-clause"><strong>Disadvantages of the Dynamic Where Clause</strong></h2>
<p>One potential disadvantage of using the dynamic where clause is that it can lead to code that is difficult to maintain. When you are constructing complex SQL queries on the fly, it can be easy to create code that becomes hard to read and understand over time. Additionally, if you are not careful, you may end up with queries that are vulnerable to SQL injection attacks.</p>
<p>Another disadvantage of the dynamic where clause is that it can be slower than constructing queries manually. This is because the dynamic where clause requires Laravel to parse the conditions you specify and generate the appropriate SQL on the fly. In some cases, this can result in slower query execution times.</p>
<p>However, there are ways to mitigate these disadvantages. For example, you can use Laravel’s query builder to construct your queries in a more structured manner, which can make them easier to read and maintain. Additionally, you can use Laravel’s query logging feature to identify slow queries and optimize them for better performance.</p>
<h2 id="heading-examples"><strong>Examples</strong></h2>
<p>To illustrate how the dynamic where clause works, let’s take a look at two examples: <code>whereEmail</code> and <code>whereName</code>. These methods allow you to search your database for records based on a user’s email address or name, respectively.</p>
<p>Here is an example of how you might use the whereEmail method to search for users with a specific email address:</p>
<pre><code class="lang-php">$user = User::whereEmail(<span class="hljs-string">'info@webcapsules.com'</span>)-&gt;first();
</code></pre>
<p>In this example, we are using the dynamic where clause to construct a query that searches for a user with the email address ”<a target="_blank" href="mailto:info@codewithdary.com"><strong>info@webcapsules.com</strong></a>”. The ‘first()’ method returns the first user that matches this criteria.</p>
<p>Similarly, you can use the whereName method to search for users by name:</p>
<pre><code class="lang-php">$users = User::whereName(<span class="hljs-string">'Muhammady'</span>)-&gt;get();
</code></pre>
<p>In this example, we are using the dynamic where clause to construct a query that searches for all users with the name “John”. The ‘get()’ method returns all users that match this criteria.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>While the dynamic where clause in Laravel may not be as well-known or widely-discussed as some other features, it can be a powerful tool in your development arsenal. By using this feature, you can build flexible, customizable queries that allow your users to search for specific attributes in your database.</p>
<p>However, it is important to be aware of the potential disadvantages of using the dynamic where clause, such as code that is difficult to maintain and slower query execution times. As with any feature in Laravel, it is important to weigh the pros and cons carefully and use the dynamic where clause judiciously. By doing so, you can take advantage of its benefits and avoid its pitfalls to build better, more efficient applications.</p>
]]></content:encoded></item></channel></rss>