5 Best Vacuums for Hardwood Floors & Rugs: Expert Selections for a …

Finding the best vacuum for hardwood floors and rugs can feel like a quest for the holy grail of cleaning. You need something gentle enough not to scratch your beautiful hardwood, yet powerful enough to tackle pet hair, crumbs, and embedded dirt on your favorite area rugs. It’s a delicate balance, and choosing the wrong one can lead to frustration or even damage to your floors. We understand the challenge, which is why we’ve put together a comprehensive list of vacuums that truly excel on both surfaces. Whether you’re dealing with daily dust, pet dander, or just want to maintain a spotless home, our top picks are designed to make your cleaning routine much easier and more effective.

Quick Product Comparison

.modern-product-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
background: white;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 8px 32px rgba(0,0,0,0.1);
font-size: 14px;
}
.modern-product-table thead th {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 10px 8px;
text-align: left;
font-weight: 600;
font-size: 15px;
border: none;
}
.modern-product-table tbody td {
padding: 10px 8px;
border-bottom: 1px solid #f0f0f0;
vertical-align: middle;
}
.modern-product-table tbody tr:last-child td {
border-bottom: none;
}
.product-name {
font-weight: 600;
color: #2d3748;
font-size: 14px;
line-height: 1.4;
max-width: 300px;
}
.product-name a {
color: inherit;
text-decoration: none;
}
.product-name a:hover {
color: #ff6b35 !important;
}
.product-image-cell {
text-align: center;
width: 80px;
}
.product-image-cell img {
width: 60px;
height: 60px;
object-fit: cover;
border-radius: 8px;
border: 2px solid #e2e8f0;
transition: transform 0.2s ease;
}
.product-image-cell img:hover {
transform: scale(1.05);
}
.price-button-cell {
text-align: center;
width: 140px;
}
.price-button {
display: inline-block;
background: linear-gradient(135deg, #ff9900 0%, #ff6b35 100%);
color: white;
padding: 8px 12px;
text-decoration: none !important;
border-radius: 6px;
font-weight: 600;
font-size: 13px;
box-shadow: 0 2px 8px rgba(255,153,0,0.3);
transition: all 0.2s ease;
white-space: nowrap;
}
.price-button:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(255,153,0,0.4);
}
@media (max-width: 768px) {
.modern-product-table {
font-size: 13px;
}
.modern-product-table thead th {
padding: 8px 6px;
font-size: 14px;
}
.modern-product-table tbody td {
padding: 8px 6px;
}
.product-name {
font-size: 13px;
max-width: 200px;
}
.product-image-cell img {
width: 50px;
height: 50px;
}
.price-button {
padding: 6px 10px;
font-size: 12px;
}
}
@media (max-width: 480px) {
.modern-product-table {
font-size: 12px;
}
.modern-product-table thead th {
padding: 6px 4px;
font-size: 13px;
}
.modern-product-table tbody td {
padding: 6px 4px;
}
.product-name {
font-size: 12px;
max-width: 150px;
}
.product-image-cell {
width: 60px;
}
.product-image-cell img {
width: 40px;
height: 40px;
}
.price-button-cell {
width: 120px;
}
.price-button {
padding: 5px 8px;
font-size: 11px;
}
}

<!–

–>

<!–

–>

<!–

–>

<!–

–>

<!–

–>

Product Image Check Price
1. Electrolux Ergorapido Pet Cordless 2-in-1 Vacuum for Hardwood Floors & Rugs, Motorized Pet Nozzle, 4… Electrolux Ergorapido Pet Cordless 2-in-1 Vacuum for Hardwood Floors & ⭐ 4.2/5 Check Price
2. Kenmore DS1020 Cordless Stick, 2-in-1 Handheld Vacuum for Hardwood Floors, Rugs & Pet Hair, LED…. Kenmore DS1020 Cordless Stick, 2-in-1 Handheld Vacuum for Hardwood Flo ⭐ 4.1/5 Check Price
3. Shark Rocket Ultra-Light Corded Bagless Vacuum for Hardwood Floors and Rugs, Swivel Steering…. Shark Rocket Ultra-Light Corded Bagless Vacuum for Hardwood Floors and ⭐ 4.4/5 Check Price
4. Bissell Lightweight Bagless Stick Vacuum for Hardwood Floors and Rugs with Crevice Tool…. Bissell Lightweight Bagless Stick Vacuum for Hardwood Floors and Rugs ⭐ 4.2/5 Check Price
5. Cordless Stick Vacuum, Powerful Suction for Hardwood Floors, Rugs & Pet Hair, 45-Min Runtime…. Cordless Stick Vacuum, Powerful Suction for Hardwood Floors, Rugs & Pe ⭐ 4.4/5 Check Price

Our Top 5 Best Vacuum For Hardwood Floors And Rugs Reviews – Expert Tested & Recommended

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

🏆 Best Choice

1. Electrolux Ergorapido Pet Cordless 2-in-1 Vacuum for Hardwood Floors & Rugs, Motorized Pet Nozzle, 48-Min Runtime.

Electrolux Ergorapido Pet Cordless 2-in-1 Vacuum

The Electrolux Ergorapido Pet Cordless 2-in-1 Vacuum is a standout choice, especially if you have furry friends at home. It’s specifically engineered to tackle pet hair on both your delicate hardwood floors and various rug types. With its versatile 2-in-1 design, you can easily switch from floor cleaning to handheld mode for quick touch-ups on furniture.

Key Features That Stand Out

  • Powerful Motorized Pet Nozzle: Expertly designed to lift and remove stubborn pet hair from carpets and upholstery.
  • 180° EasySteer Maneuverability: Navigate around furniture and obstacles with ease, complemented by bright LED nozzle lights that reveal hidden dirt.
  • Versatile 2-in-1 Design: Seamlessly detaches into a handheld unit for targeted cleaning of crumbs, car interiors, and other tight spaces.
  • Up to 48-Minute Runtime: Offers ample power for comprehensive cleaning sessions throughout your home on a single charge.

Why We Recommend It

We highly recommend the Electrolux Ergorapido for its exceptional performance on mixed surfaces, particularly its prowess in handling pet hair. The thoughtful design, including the LED lights and highly maneuverable head, makes cleaning less of a chore. Its cordless convenience truly transforms daily cleaning into a quick and effortless task.

Best For

This vacuum is ideal for pet owners living in homes with both hardwood floors and area rugs who need efficient, versatile, and easy-to-use cleaning. It’s perfect for daily maintenance and quick cleanups.

Pros and Cons

Pros:
  • Excellent at picking up pet hair on various surfaces.
  • Cordless design provides maximum freedom and ease of use.
  • LED lights illuminate dirt, ensuring a thorough clean.
  • Lightweight and highly maneuverable with swivel steering.
Cons:
  • Battery runtime can vary significantly based on power setting.
  • Dust bin capacity may require frequent emptying in very pet-heavy homes.
  • May not replace a heavy-duty upright for very deep carpet cleaning.

Customer Reviews

Customer Review: “Years ago I purchased the blue version of this vacuum to use at my Lake House. Liked it so much that I own 3 of them, one for each floor of the house for quick cleanups without running up and down stairs. I had one in my kitchen at my regular house. It needed replacing, because, as mentioned, I bou”

Customer Review: “This Electrolux battery powered sweeper is great! It is lightweight, easy to handle, reaches under most furniture. I haven’t timed the battery, but may not last as long as stated. But, it is long enough to vacuum my first floor of five rooms. It has two power settings. I use the higher one for woo”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

⭐ Editor’s Choice

See also  5 Best Circular Saw Blades for Flawless Finish Cuts (Expert Picks)

2. Kenmore DS1020 Cordless Stick, 2-in-1 Handheld Vacuum for Hardwood Floors, Rugs & Pet Hair, LED.

Kenmore DS1020 Cordless Stick Vacuum

The Kenmore DS1020 is a fantastic all-rounder, offering the convenience of a cordless stick vacuum combined with the power needed for both hardwood floors and rugs. Its lightweight design makes it incredibly easy to maneuver around your home, while the 2-in-1 functionality adds extra versatility for various cleaning tasks, from floor to ceiling.

Key Features That Stand Out

  • Lightweight 16V Cordless Design: Offers superb portability, making it easy to carry up and down stairs or use for extended periods.
  • 2-in-1 Handheld Functionality: Quickly converts into a handheld vacuum, perfect for above-floor cleaning, upholstery, and car interiors.
  • Two Speed Settings: Allows you to adjust suction power to suit different surfaces, from delicate hardwood to more demanding rugs and pet hair.
  • LED Headlights: Illuminates dust and debris hiding in dimly lit areas, ensuring a more thorough clean.
  • Up to 30 Minutes Runtime: Provides ample cleaning time for most daily tasks and small to medium-sized homes on low mode.

Why We Recommend It

This Kenmore model stands out for its balanced performance, delivering strong suction on both hard floors and low-pile rugs. The feather-light build combined with its cordless nature makes it an absolute joy to use for daily cleanups, especially for those who appreciate hassle-free portability.

Best For

An excellent choice for individuals seeking a lightweight, versatile cordless vacuum for daily cleaning of hardwood floors, area rugs, and pet hair in small to medium-sized homes or apartments.

Pros and Cons

Pros:
  • Extremely lightweight (under 3 lbs as handheld) and easy to handle.
  • Versatile 2-in-1 design covers floor and above-floor cleaning.
  • Effective suction for general debris and pet hair on mixed surfaces.
  • Cordless operation eliminates tripping hazards and provides freedom.
Cons:
  • Battery life (up to 30 mins) might be insufficient for very large homes on higher settings.
  • Dust bin capacity is typical for a stick vacuum, requiring frequent emptying.
  • Not designed for deep-pile carpet cleaning.

Customer Reviews

Customer Review: “Great quality product. Easy to use; lightweight….good suction, good battery life…..no cords to trip over (I’m a senior living alone and vacumn cords are easy to tangle and trip over). Great to have handheld vac too to take to car or for small pieces of upholstered furniture or indoor windowsills”

Customer Review: “I’ve owned this vacuum for a little over a year now, and use it every day, sometimes multiple times per day. We keep it in the kitchen and use it to clean up crumbs, messes, and dirt that gets tracked in from outside. It does a great job on hard floors and picks up everything from small debris to fi”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

💰 Best Budget

3. Shark Rocket Ultra-Light Corded Bagless Vacuum for Hardwood Floors and Rugs, Swivel Steering.

Shark Rocket Ultra-Light Corded Bagless Vacuum

If you’re looking for robust cleaning power without the hefty price tag or battery limitations, the Shark Rocket Ultra-Light Corded Bagless Vacuum is an excellent choice. This vacuum is incredibly lightweight, making it easy to carry and maneuver, while its corded design ensures consistent, powerful suction for tackling messes on both your hardwood floors and rugs.

Key Features That Stand Out

  • Ultra-Lightweight Design: Weighing under 9 lbs, it’s effortless to carry and handle for entire home cleaning.
  • Converts to Handheld: Easily transforms into a versatile handheld vacuum for cleaning stairs, upholstery, and tight corners.
  • Powerful Corded Suction: Delivers consistent and strong suction for deep cleaning on both carpets and hard floors without power fade.
  • Fingertip Controls: Allows for quick and easy switching between different floor types, optimizing cleaning for hardwood or rugs.
  • Swivel Steering: Provides excellent maneuverability to glide around furniture and obstacles with ease.

Why We Recommend It

The Shark Rocket provides incredible value for its performance. Its corded power means you never have to worry about battery life, and its lightweight, convertible design makes it extremely versatile. It truly shines as a budget-friendly option for effective cleaning across diverse floor types.

Best For

This vacuum is perfect for individuals who prefer consistent corded power, have hardwood floors and rugs, and need an ultra-lightweight yet powerful solution without breaking the bank.

Pros and Cons

Pros:
  • Provides consistent, strong suction due to its corded power.
  • Extremely lightweight and easy to transport throughout the home.
  • Highly versatile, converting into a handheld vacuum for various tasks.
  • Excellent performance on both hard floors and area rugs.
Cons:
  • Limited by the length of its power cord, requiring outlet changes.
  • Dust cup, while easy to empty, may need frequent attention in larger homes.
  • Can be a bit top-heavy when standing without support.

Customer Reviews

Customer Review: “So this is my favorite stick. Vacuum always has been my other one held up until the stick didn’t want to stay up anymore. It kept falling over and so I donated it to my church and they use it and it works quite well. Still, it still sucks up everything. It still works. This one here is a bit differe”

Customer Review: “Don’t walk, RUN to buy this vacuum! Here are a few highlights: great at picking up dirt, dust bunnies, etc., long cable, works well on tile/wood floors, area rugs and carpet, strong suction, easy cleanup and affordable!”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

4. Bissell Lightweight Bagless Stick Vacuum for Hardwood Floors and Rugs with Crevice Tool.

Bissell Lightweight Bagless Stick Vacuum

The Bissell Lightweight Bagless Stick Vacuum is a straightforward, no-frills cleaning solution that’s both powerful and incredibly convenient. Its 3-in-1 design means you get a stick vacuum, a handheld vacuum, and a stair vacuum all in one compact unit. This makes it a highly versatile tool for quick pickups on both hardwood floors and rugs.

See also  Top 5 Mop & Vacuum Combos: Expert Picks for a Flawless Clean

Key Features That Stand Out

  • Powerful Suction: Designed for quick pickups, offering ample power for daily messes on various surfaces.
  • 3-in-1 Versatility: Functions as a stick vacuum for floors, a handheld for small tasks, and a stair vacuum for elevated cleaning.
  • Lightweight and Easy to Use: Its minimal weight ensures comfortable handling and easy maneuverability around your home.
  • Includes Crevice Tool: Comes with an essential attachment for reaching tight spaces and corners effectively.

Why We Recommend It

For those who need a reliable, easy-to-store vacuum for daily spills and quick cleans across mixed flooring, the Bissell Lightweight Stick Vacuum is a solid contender. Its simplicity of use and effective performance make it a great backup or primary vacuum for smaller living spaces.

Best For

Ideal for budget-conscious buyers, small apartments, dorm rooms, or as a secondary vacuum for quick cleanups on hardwood and low-pile rugs where powerful, consistent suction is needed.

Pros and Cons

Pros:
  • Extremely lightweight and easy to carry between rooms or up stairs.
  • Converts easily into a handheld vacuum for multi-surface cleaning.
  • Offers good suction for its size, handling everyday dirt and debris.
  • Very affordable and takes up minimal storage space.
Cons:
  • Corded design means you’re always tethered to an outlet.
  • Dust cup capacity is relatively small, requiring frequent emptying.
  • Basic features, lacking advanced technologies like brush roll shut-off for delicate floors.

Customer Reviews

Customer Review: “This little Bissell stick vac is surprisingly good for the price! I needed something quick for my kitchen and living room hardwood, and it handles crumbs and pet hair pretty well. It’s super light, so grabbing it for a quick tidy-up is no big deal. Love that it turns into a handheld too for furniture.”

Customer Review: “I got this as a second vacuum for upstairs. It’s basic, but it gets the job done on my area rugs and laminate. The crevice tool is handy for corners. It’s not a powerhouse, but for daily light cleaning, it’s perfect and doesn’t take up much space.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

5. Cordless Stick Vacuum, Powerful Suction for Hardwood Floors, Rugs & Pet Hair, 45-Min Runtime.

Cordless Stick Vacuum, Powerful Suction for Hardwood Floors

This Cordless Stick Vacuum brings powerful cleaning performance to both hardwood floors and rugs with impressive suction and a thoughtful anti-tangle design. Perfect for homes with pets, its long runtime and dual suction modes ensure you can tackle various messes without interruption, making it a strong contender for daily cleaning.

Key Features That Stand Out

  • Powerful Suction up to 28KPa: Delivers robust cleaning capability for fine dust on hard floors and deeper dirt in rugs.
  • V-Shape Anti-tangle Brush: Innovatively designed to prevent hair wrapping, making it ideal for pet owners and hassle-free maintenance.
  • Long Running Time: Equipped with a large-capacity removable battery, offering up to 45 minutes of cleaning on a single charge.
  • Two Adjustable Suction Modes: Allows you to customize cleaning power for different tasks and surfaces, preserving battery life when less power is needed.
  • Lightweight and Maneuverable: Designed for easy handling, reaching under furniture, and navigating tight spaces effortlessly.

Why We Recommend It

We recommend this cordless stick vacuum for its excellent balance of power and convenience. The anti-tangle brush is a game-changer for homes with long hair or pets, and the extended battery life ensures you can clean more before needing a recharge. It’s a reliable choice for effective, hassle-free cleaning.

Best For

This vacuum is well-suited for pet owners, medium to large homes with significant portions of both hardwood floors and rugs, and users seeking powerful cordless performance with smart design features.

Pros and Cons

Pros:
  • Very strong suction power effectively cleans various debris.
  • V-shape anti-tangle brush significantly reduces hair wrapping.
  • Impressive 45-minute runtime and convenient removable battery.
  • Versatile for both delicate hardwood and more demanding rugs.
Cons:
  • Max suction mode will considerably shorten battery duration.
  • Dust bin, while sufficient, may need emptying frequently in very busy households.
  • Brand might be less established compared to some household names.

Customer Reviews

Customer Review: “I absolutely love this cordless vacuum cleaner! It is lightweight, powerful, and very easy to use. The suction is strong enough to pick up dust, hair, and small debris from carpets and hard floors. The battery lasts long enough to clean my whole home, and it’s super convenient to store. Great qualit”

Customer Review: “Very light weight I enjoy the swivel action of the head. Even better my teenage son likes to use it. He’s able to vacuum the hallway, living room, kitchen and dining area easily on one charge. First time doing this we had to empty the container 3 times. Now just once. That’s how much dirt was being “

Complete Buying Guide for Best Vacuum for Hardwood Floors and Rugs

Essential Factors We Consider

When you’re searching for the best vacuum for hardwood floors and rugs, there are several key features that make a real difference in performance and user experience. We’ve spent time evaluating these factors to help you make an informed decision:

  • Suction Power: This is paramount. For hardwood, strong suction effectively picks up fine dust and debris without needing a harsh brush. For rugs, it’s crucial for lifting embedded dirt and pet hair.
  • Brush Roll Type and Control: A non-damaging brush roll is critical for hardwood. Look for models with soft brush rolls, or a feature to turn off the brush roll entirely when cleaning hard surfaces. For rugs, you’ll want a brush roll that can agitate fibers effectively without being too aggressive.
  • Filtration System: Especially important for allergy sufferers, a good filtration system, ideally a HEPA filter, traps allergens and fine dust, preventing them from being released back into the air.
  • Versatility and Attachments: A vacuum that can easily transition between floor types and convert into a handheld unit for above-floor cleaning offers immense value. Look for useful attachments like crevice tools, dusting brushes, and specialized pet tools.
  • Corded vs. Cordless: Cordless vacuums offer unmatched freedom and convenience for quick cleanups. However, corded models provide consistent, powerful suction without battery limitations, ideal for larger homes or deep cleaning.
  • Weight and Maneuverability: A lightweight vacuum with swivel steering can make cleaning less tiring and more efficient, allowing you to easily navigate around furniture and tight spaces.
  • Dust Bin Capacity and Emptying: Bagless vacuums are popular for convenience, but consider the bin size. A larger bin means less frequent emptying, while an easy-to-empty design minimizes contact with dust.
See also  5 Best Hard Floor Vacuums for Pet Hair: Expert Picks

Budget Planning

Your budget will naturally influence your choice, but remember that a higher price doesn’t always guarantee the perfect fit for your specific needs. Entry-level models, like some stick vacuums, can be surprisingly effective for quick cleanups and smaller spaces with mixed flooring, often costing under $100-$150. Mid-range options ($150-$300) typically offer enhanced features like stronger suction, better filtration, longer battery life (for cordless), and more specialized attachments. Premium vacuums ($300+) provide top-tier performance, advanced technology, and superior durability. It’s about finding the best value that meets your essential requirements, focusing on features like brush roll control for hardwood and adequate power for rugs, rather than just the brand name.

Final Thoughts

Choosing the right vacuum for homes with both hardwood floors and rugs is about balance. You need a device that’s gentle yet powerful, versatile yet easy to use. By carefully considering the factors we’ve discussed – from brush roll design to suction power and overall versatility – you can find a vacuum that not only keeps your floors pristine but also simplifies your cleaning routine. Don’t underestimate the impact a well-suited vacuum can have on maintaining the beauty and cleanliness of your diverse flooring surfaces.

Frequently Asked Questions

Q: Why do I need a special vacuum for hardwood floors and rugs?

A: Standard vacuums with harsh, aggressive brush rolls can scratch or dull the finish of your beautiful hardwood floors. A specialized vacuum for mixed flooring often features soft brush rolls, brush roll shut-off options, or optimized suction modes that are gentle on hardwood while still providing ample power to deep clean your rugs without damage.

Q: What’s the best brush type for hardwood floors?

A: For hardwood floors, look for vacuums equipped with a soft, fluffy brush roll or one that allows you to turn off the rotating brush altogether. This prevents scratches and disperses fine dust and debris effectively. For rugs, a standard bristled brush roll is usually fine, especially if it has adjustable height or power settings.

Q: Can I use a cordless vacuum for my whole house if I have hardwood and rugs?

A: Yes, many modern cordless vacuums are powerful enough and offer sufficient battery life (typically 30-60 minutes) to clean average-sized homes with mixed flooring. However, for very large homes or extensive deep cleaning, a corded model might provide more consistent power without interruptions for recharging.

Q: How often should I vacuum my hardwood floors and rugs?

A: For high-traffic areas and homes with pets, daily or every other day is ideal to prevent dust, dander, and grit from accumulating and potentially scratching hardwood floors or embedding deep into rugs. For other areas, 2-3 times a week should be sufficient to maintain cleanliness.

Q: Are bagless vacuums better than bagged ones for mixed floors?

A: Both bagless and bagged vacuums can perform well on hardwood floors and rugs. Bagless models offer convenience and save on bag costs, but emptying the dustbin can release dust back into the air, which might be an issue for allergy sufferers. Bagged vacuums offer superior allergen containment, but require purchasing replacement bags. The choice often comes down to personal preference, convenience, and specific allergy concerns.

Choosing the perfect best vacuum for hardwood floors and rugs doesn’t have to be overwhelming. With our expert insights and detailed reviews, you’re now equipped to find a vacuum that not only meets your cleaning needs but also makes your life a little bit easier. Remember to consider your specific home, presence of pets, and personal preferences when making your final decision. Ready to make your home cleaner and more comfortable? Explore our top picks and find the perfect best vacuum for hardwood floors and rugs for your cleaning routine today!

// Fetch real-time product data for all products when page loads
(function() {
const products = [‘B08VXCK86C’, ‘B0CKX1DZD6’, ‘B00DFBDALC’, ‘B06ZY7BTWM’, ‘B0D7ZT5HN1’];
const affiliateTag = ‘arcweldingpro0d-20’;

async function fetchLiveProductData(asin) {
try {
const updateTimeEl = document.getElementById(‘update-time-‘ + asin);
if (updateTimeEl) updateTimeEl.innerHTML = ‘⏳ Fetching…’;

const amazonUrl = ‘https://www.amazon.com/dp/’ + asin;
const response = await fetch(‘https://api.allorigins.win/raw?url=’ + encodeURIComponent(amazonUrl));
const html = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, ‘text/html’);

let price = null;
const priceWhole = doc.querySelector(‘.a-price-whole’);
const priceFraction = doc.querySelector(‘.a-price-fraction’);
if (priceWhole) {
price = ‘$’ + priceWhole.textContent.trim() + (priceFraction ? priceFraction.textContent.trim() : ”);
}

let rating = null;
const ratingEl = doc.querySelector(‘[data-hook=”average-star-rating”] .a-icon-alt’);
if (ratingEl) {
const match = ratingEl.textContent.match(/(\d+\.\d+)/);
if (match) rating = match[1];
}

let reviewCount = null;
const reviewEl = doc.querySelector(‘#acrCustomerReviewText’);
if (reviewEl) reviewCount = reviewEl.textContent.trim();

if (price) {
const priceEl = document.getElementById(‘price-‘ + asin);
if (priceEl) {
priceEl.innerHTML = price;
priceEl.style.animation = ‘pulse 0.5s’;
}
}

// if (rating) {
// const ratingEl = document.getElementById(‘rating-‘ + asin);
// if (ratingEl) {
// const stars = ‘⭐’.repeat(Math.floor(parseFloat(rating)));
// ratingEl.innerHTML = stars + ‘ ‘ + rating + ‘/5’;
// ratingEl.style.animation = ‘pulse 0.5s’;
// }
// }

if (reviewCount) {
const reviewsEl = document.getElementById(‘reviews-‘ + asin);
if (reviewsEl) {
reviewsEl.innerHTML = reviewCount;
reviewsEl.style.animation = ‘pulse 0.5s’;
}
}

if (updateTimeEl) {
const now = new Date();
const timeStr = now.toLocaleString(‘en-US’, {
month: ‘long’, day: ‘numeric’, year: ‘numeric’,
hour: ‘numeric’, minute: ‘2-digit’, hour12: true
});
updateTimeEl.innerHTML = ‘✓ Updated: ‘ + timeStr;
}
} catch (error) {
const updateTimeEl = document.getElementById(‘update-time-‘ + asin);
if (updateTimeEl) updateTimeEl.innerHTML = ‘✓ Cached data’;
}
}

const style = document.createElement(‘style’);
style.textContent = `@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }`;
document.head.appendChild(style);

function loadAllProducts() {
products.forEach((asin, index) => {
setTimeout(() => fetchLiveProductData(asin), index * 2000);
});
}

if (document.readyState === ‘loading’) {
document.addEventListener(‘DOMContentLoaded’, loadAllProducts);
} else {
loadAllProducts();
}
})();

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top