Maybe you should use something like Adobe Animate.
If it's a simple animation you can do this in Photoshop, otherwise as Derek suggested use something like Animate CC.
Create multiple layers with your animation sequence in mind.
Open up the Timeline - Window > Timeline
Create a video timeline
Move & extend Layer clips through time to create your sequenced animation
Export as a GIF.
File > Export > Save for Web (Legacy...)
Choose GIF and loop infinitely.
Embed GIF into your website.