5 jQuery snippets for almost every website
There are some snippets that are repeated in almost every project. So here are my honorable mentions:
- Broken images fix
This one is my favorite. When you are rendering images from some other source and if there is an error ( broken url or image not there) then this fix will take care of you.
Just have a fallback image in your folders. Even if that’s not the case it’s still very useful. Keeping it on won’t cause any errors.
2. Back to top button
It works in a very simple way. Whenever you click on the link ( or make it a button if you wish ) it will take you to the top . You can adjust the speed of transition by changing the number 800 ( milliseconds ) to whatever you like.
3. Sliding from one part to another
It’s a different version of what we defined above. Even though it does the same thing still you will be tempted to use it in you nav bar. You can use it to slide from one part to another.
You can have a callback attached to perform some function when you reach your destination (some pop up message maybe ) or just go to your destination simply like in the second one.
4. Page Load time
You can check other functions by typing window.performance in your Developer tools.
5. Put a flash message
This code will generate a flash message on top of everything because we are selecting body. You can put it wherever you like and the properties defined in style can be done in style sheet separately.
So these were the snippets that come in handy to me.
You don’t agree?
Comment your favorite and let me know.