
Code Hacks is your go-to resource for WordPress, PHP, and related open-source technologies.
Joined April 2025
- Tweets74
- Following2K
- Followers49
- Likes1.3K
Coding Tip #11: Always use wp_enqueue_script() & wp_enqueue_style() in WordPress
Never hardcode <script> or <link> tags in the header!
Example:
wp_enqueue_script('my-script', get_template_directory_uri() . '/js/script.js', ['jquery'], '1.0', true);
#WordPress #CodeHacks
6
You can check my latest ReactJS Tip on my Linkedin page
linkedin.com/pulse/avoid-sta…
21
Coding Tip #9: Always use unique keys when rendering lists in React.js
✅ Helps React identify which items changed
✅ Prevents unnecessary re-renders
✅ Avoids bugs with component state
Never use the array index as key if the list can change!
#ReactJS #CodeHacks #JavaScript
Coding Tip #8: Prefer const and let over var in JavaScript
✅ const → value won’t be reassigned
✅ let → block-scoped, can be reassigned
✅ var → function-scoped & hoisted (can cause bugs)
Example:
const name = "Code Hacks";
let count = 0;
count++; // works
#JS #CodeHacks
Coding Tip #7: Use .on() instead of .click() or .bind() in jQuery
✅ Works with dynamically added elements
✅ Supports event delegation
✅ Cleaner and more future-proof code
Example:
$(document).on('click', '.btn', function() {
// your code here
});
#jQuery #CodeHacks
Coding Tip #6: Use :is() and :where() to write cleaner selectors
Instead of: .header h1, .header h2, .header h3 { ... }
Write: .header :is(h1, h2, h3) { ... }
#CodeHacks #CSS #Frontend #CodingTips
Coding Tip #5: Always use semantic HTML elements
Instead of <div class="header"> use <header>
Instead of <div class="nav"> use <nav>
Why it matters:
✅ Better accessibility
✅ Better SEO
✅ Cleaner, more maintainable code
#CodeHacks #CodingTips
Coding Tip #4: Handle Dynamically Added Elements Without Extra Event Handlers!
💡 The solution? jQuery Event Delegation!
Event delegation is especially useful for AJAX-loaded content, dynamic lists, modal interfaces, and interactive dashboards.
#CodeHacks #jQuery #web
Coding Tip #3: Make Your Website Responsive Without Writing Dozens of Media Queries!
There's a simpler solution: CSS clamp(). 🚀
The clamp() function allows you to set a minimum value, a preferred value, and a maximum value—all in one declaration.
#CodingTips #CodeHacks
27
Coding Tip #1: Use <button> for Actions, Not <a> Links
A small HTML decision can make a big difference in accessibility, usability, and maintainability.
- Use <a> when you are navigating
- Use <button> when you are performing an action
#CodeHacks #HTML5 #WebDev
22
Why alt Text Matters for Images 🖼️
It helps:
✅ Screen readers can describe meaningful images to users who cannot see them.
✅ It provides a text alternative when an image cannot be displayed.
✅ Search engines can better understand the purpose of an image.
#CodingTips #CodeHacks
1
26
Coding Tip
Use the appropriate HTML elements and input types when creating forms.
Why does this matter?
✅ type="email" provides built-in browser validation
✅ required prevents empty submissions
✅ <label> improves accessibility
#HTML #CodeHacks #WebDevelopment
13
Why semantic HTML matters:
✅ Improves accessibility
✅ Helps search engines understand your content
✅ Makes code easier to read and maintain
✅ Creates a stronger foundation for modern web development
#HTML #CodeHacks #CodingTips #FrontendDevelopment
1
25




