Posts Tagged: Web Development
Want to Receive Email Updates of New Articles About Web Development?
Join My Email NewsletterMedia Query Sass Mixin [code snippet]
Category: Code Snippets
The sass mixin below has default variable values for common breakpoints. But this mixin also allows you to write a custom value if needed.
How Do You Get the URL Parameters and Append to Href or Src of Another Element?
Category: Code Snippets
Do you want to grab the url parameters and pass them to a button href or iframe src? This is common when you are running a paid ad campaign to a landing page that links to a form on another page. You want to track the source of the form submission by duplicating the url… Read more »
Console Log JavaScript Objects to See Data Structure [code snippet]
Category: Code Snippets
When working with JavaScript objects and arrays it is often tricky to reference the correct index of the data you need. These console functions allow you to visually see the structure so that job is a bit easier. Writes your object as a data table and also dropdown menu console.table($yourObject); Writes your object as a… Read more »
Uncaught TypeError: Cannot read property ‘msie’ of undefined when upgrading to WordPress 5.5
Category: Code Snippets
Recently when upgrading an older site to WordPress 5.5 I noticed a javascript error in the console that read Uncaught TypeError: Cannot read property ‘msie’ of undefined. If you have a plugin or script that relied on an older version of jQuery it will no longer work because WordPress updated their jQuery version. In order… Read more »
Throttle or Delay JavaScript Functions When Window is Resized [code snippet]
Category: Code Snippets
Underscore.js has a popular method for throttling and debouncing functions to prevent them from firing multiple times when a window is resized. I found this delay function that works for times when you don’t need to load the entire underscore library to achieve a similar effect.
How to Change Favicon with JavaScript
Category: Code Snippets
This code comes in handy when you don’t have access to the head of the page and need to change the favicon. (function() { var link = document.querySelector(“link[rel*=’icon’]”) || document.createElement(‘link’); link.type = ‘image/x-icon’; link.rel = ‘shortcut icon’; link.href = ‘https://yourdomain.com/favicon.ico’; document.getElementsByTagName(‘head’)[0].appendChild(link); })();
How to Fire a jQuery Function When the Page is Loaded and Resized
Category: Code Snippets
When building responsive websites you often want to run a script when the page loads. But when you resize the window the layout breaks. You can use the on method to run your code if the page loads or has been resized. // run on page load and when the window is resized $(window).on(“load resize”,function(e){… Read more »
Web Font Weight and Style Mixin [Code Snippet]
Category: Code Snippets
If you are using Google Fonts or a custom web font, you probably are writing different font weights and styles. These mixins combine the two to make it really easy to update a global font style in your stylesheet.
How to Visually See What Your jQuery Selection is Selecting
Category: Code Snippets / Tutorials
I was recently working on form validation and wanted to mark a.form-group as successful if it contained a particular icon inside the label. The icon was set using PHP depending if the data existed in the database. I was writing .prev() and .parent() to try and select the wrapping .form-group but it wasn’t working and… Read more »
How to Prevent One Word Lines (widow orphan) In Website Paragraphs
Category: Code Snippets
I am often adding padding to the left and right of paragraphs to force copy down to prevent one word on a line. Or even worse, I add <br> to a word on the line above to prevent the word by itself. But this causes issues with responsive design because the <br> changes position breaking… Read more »