No no no. When doing an infinite scroller you need to do two things (one or another, or both)
1) Scroll the Background Texture
Don't create a huge texture or image for the background. Create a pattern which is an image that can be seamlessly be repeated again and again one next to another.
Then offset the pattern to give the effect of movement, but actually you are just creating a displacement of the initial coordinates. On some game engines the texture needs to be set to "repeat", but on HTML5 canvas "repeat" is the default.
Check out this two posts to learn about Patterns and the Translate command which is what you are looking for:
Canvas pattern offset
Moving the start position of canvas pattern
2) Create and Destroy obstacles (for a Game)
Have two sets of obstacles, the one currently rendering on the screen and the new one about to enter the screen. Move them left (assuming the scroller is horizontal), and as soon the first set of obstacle is off the screen, and the second set of obstacles is currently visible, destroy all objects of the first set of obstacles and create a new set off the screen into right area. This way you always have only two sets of obstacles and not an infinite number or very large number.
I usually have an invisible obstacle and the end of the obstacle set to easily detect when the obstacle is not visible anymore, by checking only one object and not all of them.
You can also do this for the background as an alternative to method 1, using a pattern texture (seamless repatable image) duplicated. Always drawing the two and moving them at the same speed, once one is out of screen to the left, move it to the right side and keep moving both left again.
I found this nice example of scrolling the background with this technique:
HTML5 Canvas Game: Panning a Background