{"id":8796,"date":"2024-01-21T17:55:00","date_gmt":"2024-01-21T17:55:00","guid":{"rendered":"https:\/\/codehim.com\/?p=8796"},"modified":"2024-01-22T15:56:10","modified_gmt":"2024-01-22T10:56:10","slug":"random-quote-generator-javascript","status":"publish","type":"post","link":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/","title":{"rendered":"Random Quote Generator JavaScript"},"content":{"rendered":"<p>This JavaScript code snippet helps you to create a random quote generator on a webpage. It generates random quotes and allows users to tweet or post them on Tumblr. It fetches quotes from a JSON file and dynamically updates the displayed quote and author. Perfect for inspiring and sharing wisdom!<\/p>\n<p>You can use this code on your website to add an engaging &#8220;Random Quote Generator&#8221; feature. It provides fresh content to your visitors, encouraging longer stays and repeat visits. Plus, it&#8217;s easy to integrate and customize for a personalized touch.<\/p>\n<h2>How to Create Random Quote Generator Javascript<\/h2>\n<p>1. First of all, load the <a href=\"https:\/\/fontawesome.com\/\" target=\"_blank\" rel=\"noopener\">Font Awesome CSS<\/a> (for icons) by adding the following CDN link into the head tag of your HTML document.<\/p>\n<pre class=\"prettyprint linenums lang-html\">&lt;link rel=\"stylesheet\" href=\"https:\/\/maxcdn.bootstrapcdn.com\/font-awesome\/4.3.0\/css\/font-awesome.min.css\" \/&gt;<\/pre>\n<p>2. After that, create the HTML structure for your Quote Generator. You can copy and paste the following HTML code into your HTML file. This code sets up the basic layout of the generator, including the quote display area and buttons.<\/p>\n<pre class=\"prettyprint linenums lang-html\">&lt;div id=\"wraper\"&gt;\r\n  &lt;div id=\"quote-box\"&gt;\r\n    &lt;div class=\"quote-text\"&gt;\r\n      &lt;i class=\"fa fa-quote-left\"&gt;&lt;\/i&gt;\r\n      &lt;span id=\"text\"&gt;&lt;\/span&gt;\r\n      &lt;i class=\"fa fa-quote-right\"&gt;&lt;\/i&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"quote-author\"&gt;-\r\n      &lt;span id=\"author\"&gt;&lt;\/span&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"buttons\"&gt;\r\n      &lt;a class=\"button\" id=\"tweet-quote\" title=\"Tweet this quote\" target=\"_top\"&gt;\r\n        &lt;i class=\"fa fa-twitter\"&gt;&lt;\/i&gt;\r\n      &lt;\/a&gt;\r\n      &lt;a class=\"button\" id=\"tumblr-quote\" title=\"Post this quote on tumblr\" target=\"_blank\"&gt;\r\n        &lt;i class=\"fa fa-tumblr\"&gt;&lt;\/i&gt;\r\n      &lt;\/a&gt;\r\n      &lt;button class=\"button\" id=\"new-quote\"&gt;New quote&lt;\/button&gt;\r\n    &lt;\/div&gt;\r\n  &lt;\/div&gt;\r\n  &lt;div class=\"footer\"&gt;\r\n    &lt;a href=\"https:\/\/codepen.io\/arciell\/\"&gt;by Arciel&lt;\/a&gt;\r\n  &lt;\/div&gt;\r\n\r\n&lt;\/div&gt;<\/pre>\n<p>3. Use the following CSS code or customize it to match your website&#8217;s design. This step ensures that your Quote Generator looks stylish and fits seamlessly with your site&#8217;s design.<\/p>\n<pre class=\"prettyprint linenums lang-css\">@import url(\"https:\/\/fonts.googleapis.com\/css?family=Raleway:400,500\");\r\n* {\r\n  margin: 0;\r\n  padding: 0;\r\n}\r\n\r\ndiv {\r\n  position: relative;\r\n  z-index: 2;\r\n}\r\n\r\nbody {\r\n  background-color: #333;\r\n  color: #333;\r\n  font-family: \"Raleway\", sans-serif;\r\n  font-weigth: 400;\r\n  display: flex;\r\n  justify-content: center;\r\n  align-items: center;\r\n  height: 100vh;\r\n}\r\n\r\n.footer {\r\n  width: 450px;\r\n  text-align: center;\r\n  margin: 15px auto 30px auto;\r\n  color: #fff;\r\n}\r\n.footer a {\r\n  font-weight: 500;\r\n  text-decoration: none;\r\n  color: #fff;\r\n}\r\n\r\n#quote-box {\r\n  border-radius: 3px;\r\n  position: relative;\r\n  width: 500px;\r\n  padding: 40px 50px;\r\n  display: table;\r\n  background-color: #fff;\r\n}\r\n#quote-box .quote-text {\r\n  text-align: center;\r\n  width: 450px;\r\n  height: auto;\r\n  clear: both;\r\n  font-weight: 500;\r\n  font-size: 2em;\r\n}\r\n#quote-box .quote-text i {\r\n  margin-right: 0.4em;\r\n  margin-left: 0.4em;\r\n}\r\n#quote-box .quote-author {\r\n  width: 450px;\r\n  height: auto;\r\n  clear: both;\r\n  padding-top: 20px;\r\n  font-size: 1.2em;\r\n  text-align: right;\r\n}\r\n#quote-box .buttons {\r\n  width: 450px;\r\n  margin: auto;\r\n  display: block;\r\n}\r\n#quote-box .buttons .button {\r\n  height: 38px;\r\n  border: none;\r\n  border-radius: 5%;\r\n  color: #fff;\r\n  background-color: #333;\r\n  outline: none;\r\n  font-size: 0.85em;\r\n  padding: 8px 18px 6px 18px;\r\n  margin-top: 20px;\r\n  opacity: 1;\r\n  cursor: pointer;\r\n}\r\n#quote-box .buttons .button:hover {\r\n  opacity: 0.9;\r\n}\r\n#quote-box .buttons .button#tweet-quote, #quote-box .buttons .button#tumblr-quote {\r\n  float: left;\r\n  padding: 0;\r\n  padding-top: 9px;\r\n  padding-bottom: 1px;\r\n  height: 30px;\r\n  width: 40px;\r\n  margin-right: 5px;\r\n  text-align: center;\r\n  align-items: center;\r\n  border-radius: 15%;\r\n  font-size: 1.2em;\r\n}\r\n#quote-box .buttons .button#new-quote {\r\n  float: right;\r\n}\r\n\r\n@media (max-width: 600px) {\r\n  .footer {\r\n    width: 100vw;\r\n  }\r\n\r\n  #quote-box {\r\n    width: 100vw;\r\n    padding: 40px 0;\r\n  }\r\n  #quote-box .quote-text {\r\n    width: 100vw;\r\n  }\r\n  #quote-box .quote-author {\r\n    width: 100vw;\r\n  }\r\n  #quote-box .buttons {\r\n    width: 100vw;\r\n  }\r\n}\r\n@media (max-width: 300px) {\r\n  body {\r\n    height: auto;\r\n  }\r\n\r\n  .footer {\r\n    margin: 0;\r\n    padding: 0;\r\n  }\r\n\r\n  #quote-box {\r\n    height: auto;\r\n    margin: 0;\r\n    padding: 0;\r\n  }\r\n  #quote-box .quote-text {\r\n    margin: 0;\r\n    padding: 0;\r\n  }\r\n  #quote-box .quote-author {\r\n    margin: 0;\r\n    padding: 0;\r\n  }\r\n  #quote-box .buttons {\r\n    margin: 0;\r\n    padding: 0;\r\n  }\r\n  #quote-box .buttons .button#tweet-quote {\r\n    margin-right: 1px;\r\n  }\r\n  #quote-box .buttons .button#tumblr-quote {\r\n    margin-right: 0;\r\n  }\r\n  #quote-box .buttons .button#new-quote {\r\n    padding: 8px 14px 6px 14px;\r\n  }\r\n}<\/pre>\n<p>4. Finally, add the following JavaScript code to your project. It fetches a list of quotes from a JSON file hosted on GitHub using the <code>fetch<\/code> API. Make sure to replace the URL with your own JSON file or source of quotes if needed.<\/p>\n<pre class=\"prettyprint linenums lang-js\">const projectName = \"Random-quote-machine\";\r\n\r\nconst colors = [\r\n  \"#16a085\",\r\n  \"#27ae60\",\r\n  \"#2c3e50\",\r\n  \"#f39c12\",\r\n  \"#e74c3c\",\r\n  \"#9b59b6\",\r\n  \"#FB6964\",\r\n  \"#342224\",\r\n  \"#472E32\",\r\n  \"#BDBB99\",\r\n  \"#77B1A9\",\r\n  \"#73A857\",\r\n  \"#ff0000\",\r\n  \"#00ff00\",\r\n  \"#0000ff\",\r\n  \"#ffff00\",\r\n  \"#ff00ff\",\r\n  \"#00ffff\",\r\n  \"#ff8800\",\r\n  \"#ff0088\",\r\n  \"#00ff88\",\r\n  \"#88ff00\",\r\n  \"#0088ff\",\r\n  \"#8800ff\",\r\n];\r\n\r\nlet currentQuote = \"\";\r\nlet currentAuthor = \"\";\r\nlet quotesData = [];\r\n\r\nfunction getQuotes() {\r\n  return fetch(\r\n    \"https:\/\/gist.githubusercontent.com\/camperbot\/5a022b72e96c4c9585c32bf6a75f62d9\/raw\/e3c6895ce42069f0ee7e991229064f167fe8ccdc\/quotes.json\"\r\n  )\r\n    .then((response) =&gt; response.json())\r\n    .then((data) =&gt; {\r\n      quotesData = data.quotes;\r\n    });\r\n}\r\n\r\nfunction getRandomQuote() {\r\n  return quotesData[Math.floor(Math.random() * quotesData.length)];\r\n}\r\n\r\nfunction getQuote() {\r\n  const randomQuote = getRandomQuote();\r\n\r\n  currentQuote = randomQuote.quote;\r\n  currentAuthor = randomQuote.author;\r\n\r\n  const tweetQuoteLink = document.getElementById(\"tweet-quote\");\r\n  tweetQuoteLink.href =\r\n    \"https:\/\/twitter.com\/intent\/tweet?hashtags=quotes&amp;related=freecodecamp&amp;text=\" +\r\n    encodeURIComponent('\"' + currentQuote + '\" ' + currentAuthor);\r\n\r\n  const tumblrQuoteLink = document.getElementById(\"tumblr-quote\");\r\n  tumblrQuoteLink.href =\r\n    \"https:\/\/www.tumblr.com\/widgets\/share\/tool?posttype=quote&amp;tags=quotes,freecodecamp&amp;caption=\" +\r\n    encodeURIComponent(currentAuthor) +\r\n    \"&amp;content=\" +\r\n    encodeURIComponent(currentQuote) +\r\n    \"&amp;canonicalUrl=https%3A%2F%2Fwww.tumblr.com%2Fbuttons&amp;shareSource=tumblr_share_button\";\r\n\r\n  const quoteText = document.querySelector(\".quote-text\");\r\n  const textElement = document.getElementById(\"text\");\r\n  quoteText.style.opacity = 0;\r\n  setTimeout(() =&gt; {\r\n    quoteText.style.opacity = 1;\r\n    textElement.textContent = randomQuote.quote;\r\n  }, 500);\r\n\r\n  const quoteAuthor = document.querySelector(\".quote-author\");\r\n  const authorElement = document.getElementById(\"author\");\r\n  quoteAuthor.style.opacity = 0;\r\n  setTimeout(() =&gt; {\r\n    quoteAuthor.style.opacity = 1;\r\n    authorElement.textContent = randomQuote.author;\r\n  }, 500);\r\n\r\n  const color = Math.floor(Math.random() * colors.length);\r\n  const color2 = Math.floor(Math.random() * colors.length);\r\n  document.documentElement.style.backgroundColor = colors[color];\r\n  document.body.style.color = colors[color];\r\n  const buttons = document.querySelectorAll(\".button\");\r\n  buttons.forEach((button) =&gt; {\r\n    button.style.backgroundColor = colors[color];\r\n  });\r\n}\r\n\r\ndocument.addEventListener(\"DOMContentLoaded\", () =&gt; {\r\n  getQuotes().then(() =&gt; {\r\n    getQuote();\r\n  });\r\n\r\n  const newQuoteButton = document.getElementById(\"new-quote\");\r\n  newQuoteButton.addEventListener(\"click\", getQuote);\r\n});\r\n<\/pre>\n<p>That&#8217;s all! hopefully, you have successfully created a Random Quote Generator using JavasSript. If you have any questions or suggestions, feel free to comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This JavaScript code snippet helps you to create a random quote generator on a webpage. It generates random quotes and&#8230;<\/p>\n","protected":false},"author":1,"featured_media":8811,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[116],"tags":[],"class_list":["post-8796","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vanilla-javascript"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Random Quote Generator JavaScript &#8212; CodeHim<\/title>\n<meta name=\"description\" content=\"Here is a free code snippet to create a Random Quote Generator JavaScript. You can view demo and download the source code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Random Quote Generator JavaScript &#8212; CodeHim\" \/>\n<meta property=\"og:description\" content=\"Here is a free code snippet to create a Random Quote Generator JavaScript. You can view demo and download the source code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"CodeHim\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codehimofficial\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-21T17:55:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-22T10:56:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Random-Quote-Generator-JavaScript.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"960\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Asif Mughal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CodeHimOfficial\" \/>\n<meta name=\"twitter:site\" content=\"@CodeHimOfficial\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Asif Mughal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/\"},\"author\":{\"name\":\"Asif Mughal\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\"},\"headline\":\"Random Quote Generator JavaScript\",\"datePublished\":\"2024-01-21T17:55:00+00:00\",\"dateModified\":\"2024-01-22T10:56:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/\"},\"wordCount\":265,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Random-Quote-Generator-JavaScript.png\",\"articleSection\":[\"Vanilla JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/\",\"url\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/\",\"name\":\"Random Quote Generator JavaScript &#8212; CodeHim\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Random-Quote-Generator-JavaScript.png\",\"datePublished\":\"2024-01-21T17:55:00+00:00\",\"dateModified\":\"2024-01-22T10:56:10+00:00\",\"description\":\"Here is a free code snippet to create a Random Quote Generator JavaScript. You can view demo and download the source code.\",\"breadcrumb\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#primaryimage\",\"url\":\"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Random-Quote-Generator-JavaScript.png\",\"contentUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Random-Quote-Generator-JavaScript.png\",\"width\":1280,\"height\":960,\"caption\":\"Random Quote Generator JavaScript\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codehim.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Vanilla JavaScript\",\"item\":\"https:\/\/codehim.com\/category\/vanilla-javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Random Quote Generator JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codehim.com\/#website\",\"url\":\"https:\/\/codehim.com\/\",\"name\":\"CodeHim\",\"description\":\"Web Design Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"alternateName\":\"Web Design Codes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codehim.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/codehim.com\/#organization\",\"name\":\"CodeHim - Web Design Code & Scripts\",\"url\":\"https:\/\/codehim.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg\",\"contentUrl\":\"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg\",\"width\":280,\"height\":280,\"caption\":\"CodeHim - Web Design Code & Scripts\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/codehimofficial\",\"https:\/\/x.com\/CodeHimOfficial\",\"https:\/\/www.instagram.com\/codehim\/\",\"https:\/\/www.linkedin.com\/company\/codehim\",\"https:\/\/co.pinterest.com\/codehim\/\",\"https:\/\/www.youtube.com\/@codehim\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\",\"name\":\"Asif Mughal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g\",\"caption\":\"Asif Mughal\"},\"description\":\"I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences. I truly enjoy what I'm doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.\",\"sameAs\":[\"https:\/\/codehim.com\"],\"url\":\"https:\/\/codehim.com\/author\/asif-mughal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Random Quote Generator JavaScript &#8212; CodeHim","description":"Here is a free code snippet to create a Random Quote Generator JavaScript. You can view demo and download the source code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Random Quote Generator JavaScript &#8212; CodeHim","og_description":"Here is a free code snippet to create a Random Quote Generator JavaScript. You can view demo and download the source code.","og_url":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/","og_site_name":"CodeHim","article_publisher":"https:\/\/www.facebook.com\/codehimofficial","article_published_time":"2024-01-21T17:55:00+00:00","article_modified_time":"2024-01-22T10:56:10+00:00","og_image":[{"width":1280,"height":960,"url":"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Random-Quote-Generator-JavaScript.png","type":"image\/png"}],"author":"Asif Mughal","twitter_card":"summary_large_image","twitter_creator":"@CodeHimOfficial","twitter_site":"@CodeHimOfficial","twitter_misc":{"Written by":"Asif Mughal","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#article","isPartOf":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/"},"author":{"name":"Asif Mughal","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed"},"headline":"Random Quote Generator JavaScript","datePublished":"2024-01-21T17:55:00+00:00","dateModified":"2024-01-22T10:56:10+00:00","mainEntityOfPage":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/"},"wordCount":265,"commentCount":0,"publisher":{"@id":"https:\/\/codehim.com\/#organization"},"image":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Random-Quote-Generator-JavaScript.png","articleSection":["Vanilla JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/","url":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/","name":"Random Quote Generator JavaScript &#8212; CodeHim","isPartOf":{"@id":"https:\/\/codehim.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#primaryimage"},"image":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Random-Quote-Generator-JavaScript.png","datePublished":"2024-01-21T17:55:00+00:00","dateModified":"2024-01-22T10:56:10+00:00","description":"Here is a free code snippet to create a Random Quote Generator JavaScript. You can view demo and download the source code.","breadcrumb":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#primaryimage","url":"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Random-Quote-Generator-JavaScript.png","contentUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Random-Quote-Generator-JavaScript.png","width":1280,"height":960,"caption":"Random Quote Generator JavaScript"},{"@type":"BreadcrumbList","@id":"https:\/\/codehim.com\/vanilla-javascript\/random-quote-generator-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codehim.com\/"},{"@type":"ListItem","position":2,"name":"Vanilla JavaScript","item":"https:\/\/codehim.com\/category\/vanilla-javascript\/"},{"@type":"ListItem","position":3,"name":"Random Quote Generator JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/codehim.com\/#website","url":"https:\/\/codehim.com\/","name":"CodeHim","description":"Web Design Code Snippets","publisher":{"@id":"https:\/\/codehim.com\/#organization"},"alternateName":"Web Design Codes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codehim.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codehim.com\/#organization","name":"CodeHim - Web Design Code & Scripts","url":"https:\/\/codehim.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/#\/schema\/logo\/image\/","url":"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg","contentUrl":"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg","width":280,"height":280,"caption":"CodeHim - Web Design Code & Scripts"},"image":{"@id":"https:\/\/codehim.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codehimofficial","https:\/\/x.com\/CodeHimOfficial","https:\/\/www.instagram.com\/codehim\/","https:\/\/www.linkedin.com\/company\/codehim","https:\/\/co.pinterest.com\/codehim\/","https:\/\/www.youtube.com\/@codehim"]},{"@type":"Person","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed","name":"Asif Mughal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g","caption":"Asif Mughal"},"description":"I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences. I truly enjoy what I'm doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.","sameAs":["https:\/\/codehim.com"],"url":"https:\/\/codehim.com\/author\/asif-mughal\/"}]}},"views":1025,"_links":{"self":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/8796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/comments?post=8796"}],"version-history":[{"count":0,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/8796\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media\/8811"}],"wp:attachment":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media?parent=8796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/categories?post=8796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/tags?post=8796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}