<?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: Samuel Amagbakhen</title>
    <description>The latest articles on DEV Community by Samuel Amagbakhen (@samuelorobosa).</description>
    <link>https://dev.to/samuelorobosa</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%2F436929%2F44d89da0-bc6d-4067-9b30-76280d2eaac1.png</url>
      <title>DEV Community: Samuel Amagbakhen</title>
      <link>https://dev.to/samuelorobosa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/samuelorobosa"/>
    <language>en</language>
    <item>
      <title>Lazy Loading with Intersection Observer API</title>
      <dc:creator>Samuel Amagbakhen</dc:creator>
      <pubDate>Sun, 01 May 2022 15:41:46 +0000</pubDate>
      <link>https://dev.to/samuelorobosa/lazy-loading-with-intersection-observer-api-4oi4</link>
      <guid>https://dev.to/samuelorobosa/lazy-loading-with-intersection-observer-api-4oi4</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;INTRODUCTION&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;So recently, I came across a better way to implement image lazy-loading on a web-page, so after a couple of articles and videos, I implemented it this way.&lt;/p&gt;

&lt;p&gt;Before we start, let's define two things.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Lazy Loading: &lt;code&gt;Lazy-loading&lt;/code&gt; is a technique used in optimizing a content on a web-page and in these article, we'll be using it in relation to image loading on a web-page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Intersection Observer API: The &lt;code&gt;Intersection Observer&lt;/code&gt; API is a browser API that provides a way for the browser to measure the position of a DOM element relative to the top of the view-port. One key thing to note is that it performs all these operations asynchronously.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, that we've defined that, let's see how we can use that to "lazy-load" images.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: HTML
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fza8ud3kqtmxcwtnblu80.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fza8ud3kqtmxcwtnblu80.png" alt="Markup" width="713" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice the images to be lazy loaded assigned a class of &lt;code&gt;lazy-img&lt;/code&gt; and a &lt;code&gt;data-src&lt;/code&gt; attribute. The links in src attributes of these images are placeholders that will load on the page initially before they are replaced by the images in the &lt;code&gt;data-src&lt;/code&gt; attribute as we scroll.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: CSS (Optional)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvcl8vqpotqpsspqavohq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvcl8vqpotqpsspqavohq.png" alt="Styling" width="713" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I decided to make the images block elements here so that they don't all show up when the DOM is loaded, that way, some images are hidden from the view-port enabling us to see the effect of lazy-loading.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: JavaScript
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzxwwquvvw85x7bdwhtq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzxwwquvvw85x7bdwhtq.png" alt="Functionality" width="713" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Intersection Observer API takes in a callback function and options guiding how the callback should be called. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;root&lt;/code&gt; option specifies the element to be used as the view-port for checking the visibility of the target DOM element. It defaults to the browser's viewport if set to null.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;threshold&lt;/code&gt; option takes in a number specifying how much of the target element should be visible before the callback is executed. In this case, I set it to 0.5 which indicates 50%.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Step - Test
&lt;/h2&gt;

&lt;p&gt;So you can see it in effect, below is an embedded code-pen showing lazy-loading implemented.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/samuelorobosa/embed/BaYaroG?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>css</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to Handle LinkedIn and Twitter Link Previews.</title>
      <dc:creator>Samuel Amagbakhen</dc:creator>
      <pubDate>Sun, 10 Apr 2022 20:36:57 +0000</pubDate>
      <link>https://dev.to/samuelorobosa/how-to-handle-linkedin-and-twitter-link-previews-23eg</link>
      <guid>https://dev.to/samuelorobosa/how-to-handle-linkedin-and-twitter-link-previews-23eg</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;INTRODUCTION&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;It's been a while I've posted an article on Dev Community, well, a while is somewhat over a year. Anyways, while I was gone,I've learnt quite a lot which I'll get into some other time.&lt;/p&gt;

&lt;p&gt;So, I was working on my portfolio site, and I decided to share the link on LinkedIn and Twitter and noticed something was wrong;&lt;/p&gt;

&lt;p&gt;The image previews and description wasn't showing up quite right, I made a couple of research and still saw I wasn't getting the image to show up. I debugged and discovered I wasn't sharing the image quite right.&lt;/p&gt;

&lt;p&gt;In this article, I'd take you through a step-by-step process of getting your link preview done properly(especially that image part, lol).&lt;/p&gt;

&lt;h2&gt;
  
  
  HANDLING THE PREVIEWS
&lt;/h2&gt;

&lt;p&gt;Before I start, I know some people will say this is a job for marketers and not developers but it wouldn't hurt to know bit of it. &lt;/p&gt;

&lt;p&gt;When you make a post on LinkedIn or Twitter, they take data from the meta tags on that page and preview it  for the viewers to get a glimpse of what they'll be viewing by clicking on that link. Here's an example for Linked and Twitter respectively;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7up9h19bsoz6vp2m3370.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7up9h19bsoz6vp2m3370.png" alt="LinkedIn Post Preview" width="800" height="431"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ha0906hm64sjykgqx28.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ha0906hm64sjykgqx28.png" alt="Twitter Post Preview" width="464" height="156"&gt;&lt;/a&gt; &lt;br&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  HOW CAN YOU DO THIS ON LINKEDIN
&lt;/h2&gt;

&lt;p&gt;To do this on LinkedIn, you need to include the following meta tags and make sure they are properly formatted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8icgzarbvx1ow4h4an74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8icgzarbvx1ow4h4an74.png" alt="LinkedIn Meta Tags" width="800" height="230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that LinkedIn has a couple of rules concerning the image link placed here. I'll list them below;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The maximum file size allowed is 5MB.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The minimum image dimension should be 1200px X 627px.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I encountered a problem while trying to share my image from photo hosting sites like Imgur and Google Photos so here's how I got around that issue. &lt;/p&gt;

&lt;p&gt;I uploaded the photo to Google Photos but instead of creating a link to share the image, I opened up the image, right-clicked on it to pop open the menu and copied the image address. I pasted the address in the meta tag and it worked for me. I think LinkedIn can't pull data off the shareable link because, well, it is protected. Let me know in the comment section if that doesn't work for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  HOW CAN YOU DO THIS ON TWITTER
&lt;/h2&gt;

&lt;p&gt;While LinkedIn relies on the Open Graph meta tags to preview links, Twitter does it's own a bit differently, it uses Twitter card meta tags.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tbh1l2e4683wgjocskk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tbh1l2e4683wgjocskk.png" alt="Twitter Meta Tags" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Again, I placed my url the same way I handled it for LinkedIn.&lt;/p&gt;

&lt;h2&gt;
  
  
  CONCLUSION
&lt;/h2&gt;

&lt;p&gt;So, in case you want to see how you page/site looks before actually posting them on Twitter or LinkedIn, you can use the  &lt;a href="https://www.linkedin.com/post-inspector/" rel="noopener noreferrer"&gt;LinkedIn Post Inspector Tool&lt;/a&gt; for LinkedIn Posts or &lt;a href="https://cards-dev.twitter.com/validator" rel="noopener noreferrer"&gt;Twitter Card Validator&lt;/a&gt; for Twitter Posts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;THANKS FOR READING!!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>seo</category>
      <category>html</category>
    </item>
    <item>
      <title>Parameters and Arguments..the difference</title>
      <dc:creator>Samuel Amagbakhen</dc:creator>
      <pubDate>Mon, 03 Aug 2020 15:35:43 +0000</pubDate>
      <link>https://dev.to/samuelorobosa/parameters-and-arguments-the-difference-36ko</link>
      <guid>https://dev.to/samuelorobosa/parameters-and-arguments-the-difference-36ko</guid>
      <description>&lt;p&gt;Hello, Developers...&lt;/p&gt;

&lt;p&gt;So, I remembered a definition I struggled with back then in CS class and I decided to differentiate so others could learn from it.&lt;/p&gt;

&lt;p&gt;What is the difference between &lt;/p&gt;

&lt;h4&gt;
  
  
  Parameters and Arguments?
&lt;/h4&gt;

&lt;p&gt;A lot of devs use these terms interchangeably, it's really no big deal if you're writing codes but when documenting, you want to make sure you're passing the right information across to whoever's reading your article.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Parameters are named variables which are declared during a function's definition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Arguments are the real values passed into the functions.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl1txu4ywfian75e3mfh2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl1txu4ywfian75e3mfh2.png" alt="Alt Text" width="800" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you see in the example above, the parameter in the function is the &lt;strong&gt;name&lt;/strong&gt; variable passed in during the function definition while the argument is the name &lt;strong&gt;Samuel&lt;/strong&gt; passed in during function invocation.&lt;/p&gt;

&lt;p&gt;You can use this &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Parameter" rel="noopener noreferrer"&gt;link&lt;/a&gt; as a reference to understand better.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Before You Start Coding...</title>
      <dc:creator>Samuel Amagbakhen</dc:creator>
      <pubDate>Tue, 21 Jul 2020 17:34:18 +0000</pubDate>
      <link>https://dev.to/samuelorobosa/before-you-start-coding-e2b</link>
      <guid>https://dev.to/samuelorobosa/before-you-start-coding-e2b</guid>
      <description>&lt;p&gt;Hey!! Dev Community, it's my first post here so I thought I'd go back to the basics. So, guys, let's go in.&lt;/p&gt;

&lt;p&gt;I get approached with questions like, "Samuel, I want to start coding. What do I do?"&lt;/p&gt;

&lt;p&gt;A lot of blog or articles online may just tell you to pick a language and start learning because..well, it's popular or trending or likely to rise in ranks as time goes by. I know because that's how I wrote my first "Hello World". I wrote my first code in Python and now I code in JavaScript.&lt;/p&gt;

&lt;p&gt;Okay, &lt;strong&gt;Before you start coding..&lt;/strong&gt;, what should you do?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;KNOW YOUR AIM:&lt;/strong&gt; Ask yourself this question, why am I coding? What do I want to build? Do I like the web or do I want to make desktop applications? Do I want to get into Cyber Security? Basically, I advise people looking to learn a programming language to research on &lt;strong&gt;Careers in Programming&lt;/strong&gt; and then make a choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;KNOW YOUR STACK:&lt;/strong&gt; After picking your chosen field(you could decide to switch later though..), you'd do well to know the languages needed to learn to achieve your goal. Make research based on your geographical location, that way you'd avoid learning a language that's obsolete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;START LEARNING!!&lt;/strong&gt; You could decide to get taught by registering for a Bootcamp or take an online tutorial in your chosen field. You can find online tutorials at Udemy, freeCodeCamp and a lot of other websites.&lt;/p&gt;

&lt;p&gt;Following this outline has helped me pick a field and it gives me some sort of direction. I feel like just picking any language to code is like just learning how to use a tool without knowing what to use it for.&lt;/p&gt;

&lt;p&gt;Although, some people learn languages just for educational purposes, if you looking to get into programming as a career, you should definitely choose a field.&lt;/p&gt;

&lt;p&gt;Okay guys, I guess I've enlightened you a bit, you can leave a comment if you have contributions to this post or criticisms. I'll appreciate your feedback. Have wonderful evening(yea!, I'm writing this in the evening).&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>codenewbie</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
