Code Hacks (@codehacks25) header
Code Hacks (@codehacks25) profile picture

Code Hacks is your go-to resource for WordPress, PHP, and related open-source technologies.

Joined April 2025
Photo by Code Hacks (@codehacks25)Photo by Code Hacks (@codehacks25)Photo by Code Hacks (@codehacks25)Photo by Code Hacks (@codehacks25)Photo by Code Hacks (@codehacks25)Photo by Code Hacks (@codehacks25)Photo by Code Hacks (@codehacks25)
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
Coding Tip #10: Always use prepared statements with PDO ✅ Prevents SQL injection ✅ Cleaner & safer database queries ✅ Works with MySQL and PostgreSQL Example: $stmt = $pdo->prepare("SELECT * FROM table WHERE email = ?"); $stmt->execute([$email]); $user = $stmt->fetch();
17
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
1
1
30
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
1
2
65
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
1
1
18
🤖 Made with AI
15
🤖 Made with AI
1
1
53
🤖 Made with AI
1
2
29
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
1
1
1
29
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
1
2
18
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
1
1
28
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 #2: 💡 What is lazy loading? Lazy loading allows the browser to delay loading certain images until they are close to entering the user's viewport. lazy loading improves performance, reduces bandwidth usage, and reducing unnecessary initial downloads. #HTML5 #Coding
1
1
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
HTML vs. HTML5
1
19
🤖 Made with AI
40